fix(router): Fix _lastPathIndex in deeply nested empty paths (#22394)
PR Close #22394
This commit is contained in:

committed by
Victor Berchet

parent
1e28495c89
commit
968f153491
@ -452,6 +452,45 @@ describe('recognize', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should set url segment and index properly with the "corrected" option for nested empty-path segments',
|
||||
() => {
|
||||
const url = tree('a/b') as any;
|
||||
recognize(
|
||||
RootComponent, [{
|
||||
path: 'a',
|
||||
children: [{
|
||||
path: 'b',
|
||||
component: ComponentB,
|
||||
children: [{
|
||||
path: '',
|
||||
component: ComponentC,
|
||||
children: [{path: '', component: ComponentD}]
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
url, 'a/b', 'emptyOnly', 'corrected')
|
||||
.forEach((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
const a = s.firstChild(s.root) !;
|
||||
expect(a._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
expect(a._lastPathIndex).toBe(0);
|
||||
|
||||
const b = s.firstChild(a) !;
|
||||
expect(b._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
expect(b._lastPathIndex).toBe(1);
|
||||
|
||||
const c = s.firstChild(b) !;
|
||||
expect(c._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
expect(c._lastPathIndex).toBe(1);
|
||||
|
||||
const d = s.firstChild(c) !;
|
||||
expect(d._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
expect(d._lastPathIndex).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set url segment and index properly when nested empty-path segments (2)', () => {
|
||||
const url = tree('');
|
||||
recognize(
|
||||
|
Reference in New Issue
Block a user