fix(router): handle urls with only secondary top-level segments

This commit is contained in:
vsavkin
2016-07-21 14:50:38 -07:00
parent 31a7709ece
commit 44709e0dca
4 changed files with 55 additions and 8 deletions

View File

@ -41,8 +41,9 @@ class InheritedFromParent {
export function recognize(rootComponentType: Type, config: Routes, urlTree: UrlTree, url: string):
Observable<RouterStateSnapshot> {
try {
const rootSegment = split(urlTree.root, [], [], config).segment;
const children =
processSegment(config, urlTree.root, InheritedFromParent.empty(null), PRIMARY_OUTLET);
processSegment(config, rootSegment, InheritedFromParent.empty(null), PRIMARY_OUTLET);
const root = new ActivatedRouteSnapshot(
[], Object.freeze({}), {}, PRIMARY_OUTLET, rootComponentType, null, urlTree.root, -1,
InheritedResolve.empty);
@ -127,6 +128,8 @@ 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)),