Skip to content

Commit

Permalink
refactor: makes params matching opt-out always
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 9, 2024
1 parent b0592c6 commit 35aaf15
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/operations/find-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function findAllRoutes<T>(
matches.push({
data: match.data,
params:
opts?.params && match.paramsMap
match.paramsMap && opts?.params !== false
? getMatchParams(segments, match.paramsMap)
: undefined,
});
Expand Down
12 changes: 4 additions & 8 deletions src/operations/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ export function findRoute<T = unknown>(
return;
}

if (opts?.params || !match.paramsMap) {
return {
data: match.data,
params: undefined,
};
}

return {
data: match.data,
params: getMatchParams(segments, match.paramsMap),
params:
match.paramsMap && opts?.params !== false
? getMatchParams(segments, match.paramsMap)
: undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/bench/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function createRouter(rou3: typeof rou3Src, withAll: boolean = false) {
}
if (withAll) {
return (method: string, path: string) => {
return rou3.findAllRoutes(router, method, path, { params: true }).pop();
return rou3.findAllRoutes(router, method, path).pop();
};
}
return (method: string, path: string) => {
Expand Down

0 comments on commit 35aaf15

Please sign in to comment.