mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(router): Fix outlet serialization and parsing with no primary children (#64505)
this fixes tree creation, serialization, and parsing of trees created with children outlets and no primary path fixes #62384 PR Close #64505
This commit is contained in:
committed by
Jessica Janiuk
parent
de8af17951
commit
cfd8ed3fff
@@ -728,7 +728,7 @@ class UrlParser {
|
||||
|
||||
const children = this.parseChildren();
|
||||
segments[outletName] =
|
||||
Object.keys(children).length === 1
|
||||
Object.keys(children).length === 1 && children[PRIMARY_OUTLET]
|
||||
? children[PRIMARY_OUTLET]
|
||||
: new UrlSegmentGroup([], children);
|
||||
this.consumeOptional('//');
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {exactMatchOptions, subsetMatchOptions} from '../src/router';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {exactMatchOptions, Router, subsetMatchOptions} from '../src/router';
|
||||
import {containsTree, DefaultUrlSerializer} from '../src/url_tree';
|
||||
|
||||
describe('UrlTree', () => {
|
||||
@@ -31,6 +32,14 @@ describe('UrlTree', () => {
|
||||
const tree = serializer.parse('/path/to?first=http://foo/bar?baz=true&second=123');
|
||||
expect(tree.queryParams).toEqual({'first': 'http://foo/bar?baz=true', 'second': '123'});
|
||||
});
|
||||
|
||||
it('create, serialize, parse, serialize results in same serialized tree with outlet and no primary children', () => {
|
||||
const router = TestBed.inject(Router);
|
||||
const th = router.createUrlTree(['/', {outlets: {a: ['a'], b: [{outlets: {a: ['b1']}}]}}]);
|
||||
const serialized = router.serializeUrl(th);
|
||||
const p = router.parseUrl(serialized);
|
||||
expect(router.serializeUrl(p)).toBe(serialized);
|
||||
});
|
||||
});
|
||||
|
||||
describe('containsTree', () => {
|
||||
|
||||
Reference in New Issue
Block a user