diff --git a/src/common/Routing.ts b/src/common/Routing.ts index d246adc..cbe6e07 100644 --- a/src/common/Routing.ts +++ b/src/common/Routing.ts @@ -1,4 +1,4 @@ -export type RouteParams = { [p: string]: string | number } | string[] | string | number; +export type RouteParams = { [p: string]: string | number | undefined } | string[] | string | number; export type QueryParamsRecord = Record; export type QueryParams = string[][] | QueryParamsRecord | string | URLSearchParams; @@ -43,7 +43,10 @@ export function route( path = path.replace(/\/+/g, '/'); } else { for (const key of Object.keys(params)) { - path = path.replace(getRouteParamRegExp(key), params[key].toString()); + const paramValue = params[key]; + if (paramValue) { + path = path.replace(getRouteParamRegExp(key), paramValue.toString()); + } } }