fix(router): ensuring MatchedUrl pass query params

This commit is contained in:
kurt 2016-03-31 13:04:47 +09:00 committed by Misko Hevery
parent 3ac2821a1b
commit 7d853dd9ad
2 changed files with 17 additions and 1 deletions

View File

@ -111,10 +111,10 @@ export class ParamRoutePath implements RoutePath {
for (var i = 0; i < this._segments.length; i += 1) {
var pathSegment = this._segments[i];
currentUrlSegment = nextUrlSegment;
if (pathSegment instanceof ContinuationPathSegment) {
break;
}
currentUrlSegment = nextUrlSegment;
if (isPresent(currentUrlSegment)) {
// the star segment consumes all of the remaining URL, including matrix params

View File

@ -296,6 +296,22 @@ export function main() {
});
}));
it('should match query params on the root component even when the next URL segment is null',
inject([AsyncTestCompleter], (async) => {
registry.config(RootHostCmp,
new Route({path: '/first/...', component: SingleSlashChildCmp}));
registry.recognize('/first?comments=all', [])
.then((instruction) => {
expect(instruction.component.componentType).toBe(SingleSlashChildCmp);
expect(instruction.component.params).toEqual({'comments': 'all'});
expect(instruction.child.component.componentType).toBe(DummyCmpB);
expect(instruction.child.component.params).toEqual({});
async.done();
});
}));
it('should generate URLs with matrix and query params', () => {
registry.config(
RootHostCmp,