fix(router): handle url fragments when no url segments present
This commit is contained in:
parent
8d90a5a4cf
commit
43437c175a
|
@ -294,7 +294,7 @@ class UrlParser {
|
||||||
this.capture('/');
|
this.capture('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.remaining === '' || this.remaining.startsWith('?')) {
|
if (this.remaining === '' || this.remaining.startsWith('?') || this.remaining.startsWith('#')) {
|
||||||
return new UrlSegment([], {});
|
return new UrlSegment([], {});
|
||||||
} else {
|
} else {
|
||||||
return new UrlSegment([], this.parseSegmentChildren());
|
return new UrlSegment([], this.parseSegmentChildren());
|
||||||
|
|
|
@ -1237,9 +1237,8 @@ describe('Integration', () => {
|
||||||
children: [{
|
children: [{
|
||||||
path: 'link',
|
path: 'link',
|
||||||
component: DummyLinkWithParentCmp,
|
component: DummyLinkWithParentCmp,
|
||||||
children: [
|
children:
|
||||||
{path: 'simple', component: SimpleCmp}, {path: '', component: BlankCmp}
|
[{path: 'simple', component: SimpleCmp}, {path: '', component: BlankCmp}]
|
||||||
]
|
|
||||||
}]
|
}]
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,11 @@ describe('url serializer', () => {
|
||||||
expect(url.serialize(tree)).toEqual('/one#two');
|
expect(url.serialize(tree)).toEqual('/one#two');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse fragment (root)', () => {
|
||||||
|
const tree = url.parse('/#one');
|
||||||
|
expectSegment(tree.root, '');
|
||||||
|
expect(url.serialize(tree)).toEqual('/#one');
|
||||||
|
});
|
||||||
|
|
||||||
it('should parse empty fragment', () => {
|
it('should parse empty fragment', () => {
|
||||||
const tree = url.parse('/one#');
|
const tree = url.parse('/one#');
|
||||||
|
|
Loading…
Reference in New Issue