File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 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 });
284284
285285toPath ({ id: 123 }); // => "/user/123"
286286toPath ({ id: " café" }); // => "/user/caf%C3%A9"
287- toPath ({ id: " /" }); // => "/user/%2F"
288-
289287toPath ({ id: " :/" }); // => "/user/%3A%2F"
290288
291289// 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 });
293292
294293toPathRaw ({ id: " %3A%2F" }); // => "/user/%3A%2F"
295- toPathRaw ({ id: " :/" }, { validate : false } ); // => "/user/:/"
294+ toPathRaw ({ id: " :/" }); // => "/user/:/"
296295
297296const toPathRepeated = compile (" /:segment+" );
298297
@@ -303,8 +302,6 @@ const toPathRegexp = compile("/user/:id(\\d+)");
303302
304303toPathRegexp ({ id: 123 }); // => "/user/123"
305304toPathRegexp ({ id: " 123" }); // => "/user/123"
306- toPathRegexp ({ id: " abc" }); // => Throws `TypeError`.
307- toPathRegexp ({ id: " abc" }, { validate: false }); // => "/user/abc"
308305```
309306
310307** Note:** The generated function will throw on invalid input.
You can’t perform that action at this time.
0 commit comments