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. <Mail@MPassarello.de>
This commit is contained in:
2025-05-07 19:40:08 +02:00
parent 6c4420d32f
commit b0c6901d7d
2 changed files with 2 additions and 2 deletions

View File

@@ -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<string, string | undefined>;
export type Params = Record<string, string>;

View File

@@ -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