Skip to content

Commit 44a5141

Browse files
committed
Remove key from decode type
1 parent 55fbd02 commit 44a5141

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export interface RegexpToFunctionOptions {
409409
/**
410410
* Function for decoding strings for params.
411411
*/
412-
decode?: (value: string, token: Key) => string;
412+
decode?: (value: string) => string;
413413
}
414414

415415
/**
@@ -424,11 +424,10 @@ export function regexpToFunction<P extends object = object>(
424424
const decoders = keys.map((key) => {
425425
if (key.split) {
426426
const splitRe = new RegExp(key.split, "g");
427-
return (value: string, key: Key) =>
428-
value.split(splitRe).map((part) => decode(part, key));
427+
return (value: string) => value.split(splitRe).map(decode);
429428
}
430429

431-
return (value: string, key: Key) => decode(value, key);
430+
return decode;
432431
});
433432

434433
return function match(pathname: string) {
@@ -443,7 +442,7 @@ export function regexpToFunction<P extends object = object>(
443442

444443
const key = keys[i - 1];
445444
const decoder = decoders[i - 1];
446-
params[key.name] = decoder(m[i], key);
445+
params[key.name] = decoder(m[i]);
447446
}
448447

449448
return { path, index, params };

0 commit comments

Comments
 (0)