fix(router): Fix relative link generation from empty path components (#37446)
Partial resubmit of #26243 Fixes incorrect url tree generation for empty path components with children. Adds a test to demonstrate the failure of createUrlTree for those routes. Fixes #13011 Fixes #35687 PR Close #37446
This commit is contained in:
@ -148,7 +148,12 @@ function findStartingPosition(nav: Navigation, tree: UrlTree, route: ActivatedRo
|
||||
}
|
||||
|
||||
if (route.snapshot._lastPathIndex === -1) {
|
||||
return new Position(route.snapshot._urlSegment, true, 0);
|
||||
const segmentGroup = route.snapshot._urlSegment;
|
||||
// Pathless ActivatedRoute has _lastPathIndex === -1 but should not process children
|
||||
// see issue #26224, #13011, #35687
|
||||
// However, if the ActivatedRoute is the root we should process children like above.
|
||||
const processChildren = segmentGroup === tree.root;
|
||||
return new Position(segmentGroup, processChildren, 0);
|
||||
}
|
||||
|
||||
const modifier = isMatrixParams(nav.commands[0]) ? 0 : 1;
|
||||
|
Reference in New Issue
Block a user