From b0c6901d7d272ec98b3d00ef2dd2848482892a25 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 7 May 2025 19:40:08 +0200 Subject: [PATCH] fix(params): enforce non-undefined route parameter values - Update `Params` type to disallow `undefined` values for clarity. - Default route parameter values to empty strings if `null` or `undefined`. Signed-off-by: Max P. --- src/Types/Params.ts | 2 +- src/Utils/createRouteMatcher.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Types/Params.ts b/src/Types/Params.ts index 300c211..045e056 100644 --- a/src/Types/Params.ts +++ b/src/Types/Params.ts @@ -7,4 +7,4 @@ * All values are strings and should be considered read-only, as they are * extracted by the router and should not be modified by application code. */ -export type Params = Record; +export type Params = Record; diff --git a/src/Utils/createRouteMatcher.ts b/src/Utils/createRouteMatcher.ts index 90fc2a5..97f5477 100644 --- a/src/Utils/createRouteMatcher.ts +++ b/src/Utils/createRouteMatcher.ts @@ -35,7 +35,7 @@ export function createRouteMatcher( // 3b. Extract route params const params: Params = {}; for (const [key, value] of Object.entries(result.pathname.groups)) { - params[key] = value; + params[key] = value ?? ''; // null → empty string } // 3c. Extract query parameters – keep duplicates as arrays