fix(router): disallow root segments with matrix params
This commit is contained in:
@ -19,6 +19,8 @@ export function createUrlTree(
|
||||
}
|
||||
|
||||
const normalizedCommands = normalizeCommands(commands);
|
||||
validateCommands(normalizedCommands);
|
||||
|
||||
if (navigateToRoot(normalizedCommands)) {
|
||||
return tree(urlTree.root, new UrlSegment([], {}), urlTree, queryParams, fragment);
|
||||
}
|
||||
@ -31,6 +33,12 @@ export function createUrlTree(
|
||||
return tree(startingPosition.segment, segment, urlTree, queryParams, fragment);
|
||||
}
|
||||
|
||||
function validateCommands(n: NormalizedNavigationCommands): void {
|
||||
if (n.isAbsolute && n.commands.length > 0 && (typeof n.commands[0] === 'object')) {
|
||||
throw new Error('Root segment cannot have matrix parameters');
|
||||
}
|
||||
}
|
||||
|
||||
function tree(
|
||||
oldSegment: UrlSegment, newSegment: UrlSegment, urlTree: UrlTree, queryParams: Params,
|
||||
fragment: string): UrlTree {
|
||||
|
Reference in New Issue
Block a user