common/Routing: allow RouteParams to be undefined and ignore them in this case
This commit is contained in:
parent
4c895229ec
commit
2b85bea9dd
@ -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<string, string | number | boolean | null | undefined>;
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user