File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -202,8 +202,7 @@ The `match` function returns a function for transforming paths into parameters:
202
202
- ** decode** Function for decoding strings for params, or ` false ` to disable entirely. (default: ` decodeURIComponent ` )
203
203
204
204
``` js
205
- // Make sure you consistently `decode` segments.
206
- const fn = match (" /user/:id" , { decode: decodeURIComponent });
205
+ const fn = match (" /user/:id" );
207
206
208
207
fn (" /user/123" ); // => { path: '/user/123', index: 0, params: { id: '123' } }
209
208
fn (" /invalid" ); // => false
@@ -224,15 +223,14 @@ The `compile` function will return a function for transforming parameters into a
224
223
``` js
225
224
const toPath = compile (" /user/:id" );
226
225
227
- toPath ({ id: 123 }); // => "/user/123 "
226
+ toPath ({ id: " name " }); // => "/user/name "
228
227
toPath ({ id: " café" }); // => "/user/caf%C3%A9"
229
- toPath ({ id: " :/" }); // => "/user/%3A%2F"
230
228
231
229
// When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
232
230
const toPathRaw = compile (" /user/:id" , { encode: false });
233
231
234
232
toPathRaw ({ id: " %3A%2F" }); // => "/user/%3A%2F"
235
- toPathRaw ({ id: " :/" }); // => "/user/:/", throws when `validate: false ` is not set .
233
+ toPathRaw ({ id: " :/" }); // => Throws, "/user/:/" when `validate` is `false` .
236
234
237
235
const toPathRepeated = compile (" {/:segment}+" );
238
236
You can’t perform that action at this time.
0 commit comments