File tree 1 file changed +3
-6
lines changed
1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -284,15 +284,14 @@ const toPath = compile("/user/:id", { encode: encodeURIComponent });
284
284
285
285
toPath ({ id: 123 }); // => "/user/123"
286
286
toPath ({ id: " café" }); // => "/user/caf%C3%A9"
287
- toPath ({ id: " /" }); // => "/user/%2F"
288
-
289
287
toPath ({ id: " :/" }); // => "/user/%3A%2F"
290
288
291
289
// Without `encode`, you need to make sure inputs are encoded correctly.
292
- const toPathRaw = compile (" /user/:id" );
290
+ // (Note: You can use `validate: false` to create an invalid paths.)
291
+ const toPathRaw = compile (" /user/:id" , { validate: false });
293
292
294
293
toPathRaw ({ id: " %3A%2F" }); // => "/user/%3A%2F"
295
- toPathRaw ({ id: " :/" }, { validate : false } ); // => "/user/:/"
294
+ toPathRaw ({ id: " :/" }); // => "/user/:/"
296
295
297
296
const toPathRepeated = compile (" /:segment+" );
298
297
@@ -303,8 +302,6 @@ const toPathRegexp = compile("/user/:id(\\d+)");
303
302
304
303
toPathRegexp ({ id: 123 }); // => "/user/123"
305
304
toPathRegexp ({ id: " 123" }); // => "/user/123"
306
- toPathRegexp ({ id: " abc" }); // => Throws `TypeError`.
307
- toPathRegexp ({ id: " abc" }, { validate: false }); // => "/user/abc"
308
305
```
309
306
310
307
** Note:** The generated function will throw on invalid input.
You can’t perform that action at this time.
0 commit comments