fix(router): ignore null or undefined query parameters (#12333)
This commit is contained in:

committed by
Victor Berchet

parent
79383ce150
commit
3052fb234f
@ -524,6 +524,9 @@ export class Router {
|
||||
*/
|
||||
navigate(commands: any[], extras: NavigationExtras = {skipLocationChange: false}):
|
||||
Promise<boolean> {
|
||||
if (typeof extras.queryParams === 'object' && extras.queryParams !== null) {
|
||||
extras.queryParams = this.removeEmptyProps(extras.queryParams);
|
||||
}
|
||||
return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
|
||||
}
|
||||
|
||||
@ -549,6 +552,16 @@ export class Router {
|
||||
}
|
||||
}
|
||||
|
||||
private removeEmptyProps(params: Params): Params {
|
||||
return Object.keys(params).reduce((result: Params, key: string) => {
|
||||
const value: any = params[key];
|
||||
if (value !== null && value !== undefined) {
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
private processNavigations(): void {
|
||||
concatMap
|
||||
.call(
|
||||
|
Reference in New Issue
Block a user