diff --git a/src/operations/find-all.ts b/src/operations/find-all.ts index 246a7f8..978757f 100644 --- a/src/operations/find-all.ts +++ b/src/operations/find-all.ts @@ -20,7 +20,7 @@ export function findAllRoutes( matches.push({ data: match.data, params: - opts?.params && match.paramsMap + match.paramsMap && opts?.params !== false ? getMatchParams(segments, match.paramsMap) : undefined, }); diff --git a/src/operations/find.ts b/src/operations/find.ts index 05566a2..57ef0be 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -31,16 +31,12 @@ export function findRoute( 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, }; } diff --git a/test/bench/impl.ts b/test/bench/impl.ts index a353220..77ba26d 100644 --- a/test/bench/impl.ts +++ b/test/bench/impl.ts @@ -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) => {