Skip to content

Commit 35aaf15

Browse files
committed
refactor: makes params matching opt-out always
1 parent b0592c6 commit 35aaf15

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/operations/find-all.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function findAllRoutes<T>(
2020
matches.push({
2121
data: match.data,
2222
params:
23-
opts?.params && match.paramsMap
23+
match.paramsMap && opts?.params !== false
2424
? getMatchParams(segments, match.paramsMap)
2525
: undefined,
2626
});

src/operations/find.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ export function findRoute<T = unknown>(
3131
return;
3232
}
3333

34-
if (opts?.params || !match.paramsMap) {
35-
return {
36-
data: match.data,
37-
params: undefined,
38-
};
39-
}
40-
4134
return {
4235
data: match.data,
43-
params: getMatchParams(segments, match.paramsMap),
36+
params:
37+
match.paramsMap && opts?.params !== false
38+
? getMatchParams(segments, match.paramsMap)
39+
: undefined,
4440
};
4541
}
4642

test/bench/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function createRouter(rou3: typeof rou3Src, withAll: boolean = false) {
2727
}
2828
if (withAll) {
2929
return (method: string, path: string) => {
30-
return rou3.findAllRoutes(router, method, path, { params: true }).pop();
30+
return rou3.findAllRoutes(router, method, path).pop();
3131
};
3232
}
3333
return (method: string, path: string) => {

0 commit comments

Comments
 (0)