From 7d853dd9adb8eed2e307d62f18eade47dc8e99bb Mon Sep 17 00:00:00 2001 From: kurt Date: Thu, 31 Mar 2016 13:04:47 +0900 Subject: [PATCH] fix(router): ensuring MatchedUrl pass query params --- .../src/rules/route_paths/param_route_path.ts | 2 +- .../test/route_registry_spec.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/@angular/router-deprecated/src/rules/route_paths/param_route_path.ts b/modules/@angular/router-deprecated/src/rules/route_paths/param_route_path.ts index 2b7dc4afdf..e9e80154b4 100644 --- a/modules/@angular/router-deprecated/src/rules/route_paths/param_route_path.ts +++ b/modules/@angular/router-deprecated/src/rules/route_paths/param_route_path.ts @@ -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 diff --git a/modules/@angular/router-deprecated/test/route_registry_spec.ts b/modules/@angular/router-deprecated/test/route_registry_spec.ts index cd73c73b5c..e276da47dd 100644 --- a/modules/@angular/router-deprecated/test/route_registry_spec.ts +++ b/modules/@angular/router-deprecated/test/route_registry_spec.ts @@ -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,