fix(router): simplify param merging (#22999)

This commit is contained in:
Victor Berchet
2021-03-15 08:45:56 -07:00
committed by GitHub
parent e4bf052794
commit 4ce62b26a8

View File

@ -82,18 +82,10 @@ export const matchesPath = (inputPath: string[], chain: RouteChain): RouteChain
return chain;
};
export const mergeParams = (a: any, b: any): any => {
if (!a && b) {
return b;
} else if (a && !b) {
return a;
} else if (a && b) {
return {
...a,
...b
};
}
return undefined;
// Merges the route parameter objects.
// Returns undefined when both parameters are undefined.
export const mergeParams = (a: {[key: string]: any} | undefined, b: {[key: string]: any} | undefined): {[key: string]: any} | undefined => {
return a || b ? { ...a, ...b } : undefined;
};
export const routerIDsToChain = (ids: RouteID[], chains: RouteChain[]): RouteChain | null => {