diff --git a/modules/@angular/router/src/apply_redirects.ts b/modules/@angular/router/src/apply_redirects.ts index 066245d56d..bdc2a6e1a4 100644 --- a/modules/@angular/router/src/apply_redirects.ts +++ b/modules/@angular/router/src/apply_redirects.ts @@ -342,7 +342,7 @@ function createChildrenForEmptyPaths( const res: {[name: string]: UrlSegment} = {}; res[PRIMARY_OUTLET] = primarySegment; for (let r of routes) { - if (r.path === '') { + if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) { res[getOutlet(r)] = new UrlSegment([], {}); } } diff --git a/modules/@angular/router/src/directives/router_link.ts b/modules/@angular/router/src/directives/router_link.ts index c04bccfa0b..278130e872 100644 --- a/modules/@angular/router/src/directives/router_link.ts +++ b/modules/@angular/router/src/directives/router_link.ts @@ -60,7 +60,7 @@ import {UrlTree} from '../url_tree'; component * ``` * - * The router link directive always treats it the provided input as a delta to the current url. + * The router link directive always treats the provided input as a delta to the current url. * * For instance, if the current url is `/user/(box//aux:team)`. * diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index 8c9a74b93e..1b16418181 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -128,8 +128,6 @@ function processPathsWithParamsAgainstRoute( const childConfig = getChildConfig(route); const {segment, slicedPath} = split(rawSegment, consumedPaths, rawSlicedPath, childConfig); - // console.log("raw", rawSegment) - // console.log(segment.toString(), childConfig) const snapshot = new ActivatedRouteSnapshot( consumedPaths, Object.freeze(merge(inherited.allParams, parameters)), @@ -292,7 +290,7 @@ function createChildrenForEmptyPaths( primarySegment._pathIndexShift = consumedPaths.length; for (let r of routes) { - if (r.path === '') { + if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) { const s = new UrlSegment([], {}); s._sourceSegment = segment; s._pathIndexShift = consumedPaths.length; diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index fb82c32511..65592e1d16 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -289,7 +289,7 @@ export class Router { * router.navigate(['team', 33, 'team', '11], {relativeTo: route}); * ``` * - * In opposite to `navigateByUrl`, `navigate` always takes a detla + * In opposite to `navigateByUrl`, `navigate` always takes a delta * that is applied to the current URL. */ navigate(commands: any[], extras: NavigationExtras = {}): Promise { diff --git a/modules/@angular/router/test/apply_redirects.spec.ts b/modules/@angular/router/test/apply_redirects.spec.ts index 6103d2ed50..d4064c8e4f 100644 --- a/modules/@angular/router/test/apply_redirects.spec.ts +++ b/modules/@angular/router/test/apply_redirects.spec.ts @@ -15,6 +15,7 @@ import {LoadedRouterConfig} from '../src/router_config_loader'; import {DefaultUrlSerializer, UrlSegment, UrlTree, equalPathsWithParams} from '../src/url_tree'; describe('applyRedirects', () => { + it('should return the same url tree when no redirects', () => { checkRedirect( [{path: 'a', component: ComponentA, children: [{path: 'b', component: ComponentB}]}], diff --git a/modules/@angular/router/test/recognize.spec.ts b/modules/@angular/router/test/recognize.spec.ts index c743d9572f..c011eb84e3 100644 --- a/modules/@angular/router/test/recognize.spec.ts +++ b/modules/@angular/router/test/recognize.spec.ts @@ -339,6 +339,39 @@ describe('recognize', () => { }); }); + it('should match (non-termianl) when both primary and secondary and primary has a child', + () => { + const config = [{ + path: 'parent', + children: [ + { + path: '', + component: ComponentA, + children: [ + {path: 'b', component: ComponentB}, + {path: 'c', component: ComponentC}, + ] + }, + { + path: '', + component: ComponentD, + outlet: 'secondary', + } + ] + }]; + + checkRecognize(config, 'parent/b', (s: RouterStateSnapshot) => { + checkActivatedRoute(s.root, '', {}, RootComponent); + checkActivatedRoute(s.firstChild(s.root), 'parent', {}, undefined); + + const cc = s.children(s.firstChild(s.root)); + checkActivatedRoute(cc[0], '', {}, ComponentA); + checkActivatedRoute(cc[1], '', {}, ComponentD, 'secondary'); + + checkActivatedRoute(s.firstChild(cc[0]), 'b', {}, ComponentB); + }); + }); + it('should match (terminal)', () => { checkRecognize( [{