2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 14:13:41 -04:00
|
|
|
import {Type} from '@angular/core';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
2016-06-15 19:45:19 -04:00
|
|
|
import {Observer} from 'rxjs/Observer';
|
2016-06-08 19:14:26 -04:00
|
|
|
import {of } from 'rxjs/observable/of';
|
2016-06-08 14:13:41 -04:00
|
|
|
|
2017-04-11 11:34:58 -04:00
|
|
|
import {Data, ResolveData, Route, Routes} from './config';
|
2017-11-28 19:57:10 -05:00
|
|
|
import {ActivatedRouteSnapshot, ParamsInheritanceStrategy, RouterStateSnapshot, inheritedParamsDataResolve} from './router_state';
|
2016-12-09 13:44:46 -05:00
|
|
|
import {PRIMARY_OUTLET, defaultUrlMatcher} from './shared';
|
2016-07-25 15:15:07 -04:00
|
|
|
import {UrlSegment, UrlSegmentGroup, UrlTree, mapChildrenIntoArray} from './url_tree';
|
2017-03-26 10:15:10 -04:00
|
|
|
import {forEach, last} from './utils/collection';
|
2016-06-08 14:13:41 -04:00
|
|
|
import {TreeNode} from './utils/tree';
|
2016-05-23 19:14:23 -04:00
|
|
|
|
2016-08-04 21:56:22 -04:00
|
|
|
class NoMatch {}
|
2016-06-06 13:15:23 -04:00
|
|
|
|
2016-08-10 21:21:28 -04:00
|
|
|
export function recognize(
|
2017-11-28 19:57:10 -05:00
|
|
|
rootComponentType: Type<any>| null, config: Routes, urlTree: UrlTree, url: string,
|
|
|
|
paramsInheritanceStrategy: ParamsInheritanceStrategy =
|
|
|
|
'emptyOnly'): Observable<RouterStateSnapshot> {
|
|
|
|
return new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy)
|
|
|
|
.recognize();
|
2016-05-23 19:14:23 -04:00
|
|
|
}
|
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
class Recognizer {
|
|
|
|
constructor(
|
2017-04-17 14:13:13 -04:00
|
|
|
private rootComponentType: Type<any>|null, private config: Routes, private urlTree: UrlTree,
|
2017-11-28 19:57:10 -05:00
|
|
|
private url: string, private paramsInheritanceStrategy: ParamsInheritanceStrategy) {}
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
recognize(): Observable<RouterStateSnapshot> {
|
|
|
|
try {
|
|
|
|
const rootSegmentGroup = split(this.urlTree.root, [], [], this.config).segmentGroup;
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-10-25 17:33:18 -04:00
|
|
|
const children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
|
2016-08-02 18:31:56 -04:00
|
|
|
|
|
|
|
const root = new ActivatedRouteSnapshot(
|
2017-04-17 14:13:13 -04:00
|
|
|
[], Object.freeze({}), Object.freeze(this.urlTree.queryParams), this.urlTree.fragment !,
|
|
|
|
{}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
|
2016-08-02 18:31:56 -04:00
|
|
|
|
|
|
|
const rootNode = new TreeNode<ActivatedRouteSnapshot>(root, children);
|
2016-10-25 17:33:18 -04:00
|
|
|
const routeState = new RouterStateSnapshot(this.url, rootNode);
|
2017-05-03 05:17:27 -04:00
|
|
|
this.inheritParamsAndData(routeState._root);
|
2016-10-25 17:33:18 -04:00
|
|
|
return of (routeState);
|
2016-06-02 14:30:38 -04:00
|
|
|
|
2016-06-06 13:15:23 -04:00
|
|
|
} catch (e) {
|
2016-08-04 21:56:22 -04:00
|
|
|
return new Observable<RouterStateSnapshot>(
|
|
|
|
(obs: Observer<RouterStateSnapshot>) => obs.error(e));
|
2016-06-06 13:15:23 -04:00
|
|
|
}
|
|
|
|
}
|
2016-05-23 19:14:23 -04:00
|
|
|
|
2017-05-03 05:17:27 -04:00
|
|
|
inheritParamsAndData(routeNode: TreeNode<ActivatedRouteSnapshot>): void {
|
2016-10-25 17:33:18 -04:00
|
|
|
const route = routeNode.value;
|
2016-06-19 17:44:20 -04:00
|
|
|
|
2017-11-28 19:57:10 -05:00
|
|
|
const i = inheritedParamsDataResolve(route, this.paramsInheritanceStrategy);
|
2016-10-25 17:33:18 -04:00
|
|
|
route.params = Object.freeze(i.params);
|
|
|
|
route.data = Object.freeze(i.data);
|
|
|
|
|
2017-05-03 05:17:27 -04:00
|
|
|
routeNode.children.forEach(n => this.inheritParamsAndData(n));
|
2016-10-25 17:33:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
processSegmentGroup(config: Route[], segmentGroup: UrlSegmentGroup, outlet: string):
|
|
|
|
TreeNode<ActivatedRouteSnapshot>[] {
|
2016-08-02 18:31:56 -04:00
|
|
|
if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
|
2016-10-25 17:33:18 -04:00
|
|
|
return this.processChildren(config, segmentGroup);
|
2016-08-02 18:31:56 -04:00
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
|
2016-08-02 18:31:56 -04:00
|
|
|
}
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-10-25 17:33:18 -04:00
|
|
|
processChildren(config: Route[], segmentGroup: UrlSegmentGroup):
|
2016-08-02 18:31:56 -04:00
|
|
|
TreeNode<ActivatedRouteSnapshot>[] {
|
|
|
|
const children = mapChildrenIntoArray(
|
2016-10-25 17:33:18 -04:00
|
|
|
segmentGroup, (child, childOutlet) => this.processSegmentGroup(config, child, childOutlet));
|
2016-08-02 18:31:56 -04:00
|
|
|
checkOutletNameUniqueness(children);
|
|
|
|
sortActivatedRouteSnapshots(children);
|
|
|
|
return children;
|
|
|
|
}
|
2016-06-27 17:00:07 -04:00
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
processSegment(
|
2016-12-01 16:25:53 -05:00
|
|
|
config: Route[], segmentGroup: UrlSegmentGroup, segments: UrlSegment[],
|
2016-10-25 17:33:18 -04:00
|
|
|
outlet: string): TreeNode<ActivatedRouteSnapshot>[] {
|
2016-11-12 08:08:58 -05:00
|
|
|
for (const r of config) {
|
2016-08-02 18:31:56 -04:00
|
|
|
try {
|
2016-12-01 16:25:53 -05:00
|
|
|
return this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
|
2016-08-02 18:31:56 -04:00
|
|
|
} catch (e) {
|
|
|
|
if (!(e instanceof NoMatch)) throw e;
|
|
|
|
}
|
|
|
|
}
|
2016-11-08 16:36:59 -05:00
|
|
|
if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
|
|
return [];
|
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
throw new NoMatch();
|
2016-11-08 16:36:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private noLeftoversInUrl(segmentGroup: UrlSegmentGroup, segments: UrlSegment[], outlet: string):
|
|
|
|
boolean {
|
|
|
|
return segments.length === 0 && !segmentGroup.children[outlet];
|
2016-05-23 19:14:23 -04:00
|
|
|
}
|
2016-06-06 13:15:23 -04:00
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
processSegmentAgainstRoute(
|
2016-12-01 16:25:53 -05:00
|
|
|
route: Route, rawSegment: UrlSegmentGroup, segments: UrlSegment[],
|
2016-10-25 17:33:18 -04:00
|
|
|
outlet: string): TreeNode<ActivatedRouteSnapshot>[] {
|
2016-08-02 18:31:56 -04:00
|
|
|
if (route.redirectTo) throw new NoMatch();
|
|
|
|
|
2017-03-29 12:44:04 -04:00
|
|
|
if ((route.outlet || PRIMARY_OUTLET) !== outlet) throw new NoMatch();
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2017-07-14 17:10:37 -04:00
|
|
|
let snapshot: ActivatedRouteSnapshot;
|
|
|
|
let consumedSegments: UrlSegment[] = [];
|
|
|
|
let rawSlicedSegments: UrlSegment[] = [];
|
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
if (route.path === '**') {
|
2017-04-17 14:13:13 -04:00
|
|
|
const params = segments.length > 0 ? last(segments) !.parameters : {};
|
2017-07-14 17:10:37 -04:00
|
|
|
snapshot = new ActivatedRouteSnapshot(
|
2017-04-17 14:13:13 -04:00
|
|
|
segments, params, Object.freeze(this.urlTree.queryParams), this.urlTree.fragment !,
|
|
|
|
getData(route), outlet, route.component !, route, getSourceSegmentGroup(rawSegment),
|
2016-10-25 17:33:18 -04:00
|
|
|
getPathIndexShift(rawSegment) + segments.length, getResolve(route));
|
2017-07-14 17:10:37 -04:00
|
|
|
} else {
|
|
|
|
const result: MatchResult = match(rawSegment, route, segments);
|
|
|
|
consumedSegments = result.consumedSegments;
|
|
|
|
rawSlicedSegments = segments.slice(result.lastChild);
|
|
|
|
|
|
|
|
snapshot = new ActivatedRouteSnapshot(
|
|
|
|
consumedSegments, result.parameters, Object.freeze(this.urlTree.queryParams),
|
|
|
|
this.urlTree.fragment !, getData(route), outlet, route.component !, route,
|
|
|
|
getSourceSegmentGroup(rawSegment),
|
|
|
|
getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route));
|
2016-08-02 18:31:56 -04:00
|
|
|
}
|
|
|
|
|
2017-07-14 17:10:37 -04:00
|
|
|
const childConfig: Route[] = getChildConfig(route);
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
const {segmentGroup, slicedSegments} =
|
|
|
|
split(rawSegment, consumedSegments, rawSlicedSegments, childConfig);
|
2016-07-08 17:23:23 -04:00
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
|
2016-10-25 17:33:18 -04:00
|
|
|
const children = this.processChildren(childConfig, segmentGroup);
|
2016-08-02 18:31:56 -04:00
|
|
|
return [new TreeNode<ActivatedRouteSnapshot>(snapshot, children)];
|
2017-03-29 12:44:04 -04:00
|
|
|
}
|
2016-08-02 18:31:56 -04:00
|
|
|
|
2017-03-29 12:44:04 -04:00
|
|
|
if (childConfig.length === 0 && slicedSegments.length === 0) {
|
2016-08-02 18:31:56 -04:00
|
|
|
return [new TreeNode<ActivatedRouteSnapshot>(snapshot, [])];
|
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
const children = this.processSegment(childConfig, segmentGroup, slicedSegments, PRIMARY_OUTLET);
|
|
|
|
return [new TreeNode<ActivatedRouteSnapshot>(snapshot, children)];
|
2016-05-23 19:14:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 18:31:56 -04:00
|
|
|
function sortActivatedRouteSnapshots(nodes: TreeNode<ActivatedRouteSnapshot>[]): void {
|
|
|
|
nodes.sort((a, b) => {
|
|
|
|
if (a.value.outlet === PRIMARY_OUTLET) return -1;
|
|
|
|
if (b.value.outlet === PRIMARY_OUTLET) return 1;
|
|
|
|
return a.value.outlet.localeCompare(b.value.outlet);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-11 11:34:58 -04:00
|
|
|
function getChildConfig(route: Route): Route[] {
|
2016-07-06 14:02:16 -04:00
|
|
|
if (route.children) {
|
|
|
|
return route.children;
|
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
if (route.loadChildren) {
|
2017-04-17 14:13:13 -04:00
|
|
|
return route._loadedConfig !.routes;
|
2017-03-29 12:44:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
2016-07-06 14:02:16 -04:00
|
|
|
}
|
|
|
|
|
2017-07-14 17:10:37 -04:00
|
|
|
interface MatchResult {
|
|
|
|
consumedSegments: UrlSegment[];
|
|
|
|
lastChild: number;
|
|
|
|
parameters: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
function match(segmentGroup: UrlSegmentGroup, route: Route, segments: UrlSegment[]): MatchResult {
|
2016-06-16 17:14:09 -04:00
|
|
|
if (route.path === '') {
|
2016-08-16 16:40:28 -04:00
|
|
|
if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
|
2016-06-14 17:55:59 -04:00
|
|
|
throw new NoMatch();
|
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
return {consumedSegments: [], lastChild: 0, parameters: {}};
|
2016-06-14 17:55:59 -04:00
|
|
|
}
|
2016-05-23 19:14:23 -04:00
|
|
|
|
2016-11-09 18:25:47 -05:00
|
|
|
const matcher = route.matcher || defaultUrlMatcher;
|
|
|
|
const res = matcher(segments, segmentGroup, route);
|
|
|
|
if (!res) throw new NoMatch();
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-11-09 18:25:47 -05:00
|
|
|
const posParams: {[n: string]: string} = {};
|
2017-04-17 14:13:13 -04:00
|
|
|
forEach(res.posParams !, (v: UrlSegment, k: string) => { posParams[k] = v.path; });
|
2017-03-01 15:37:28 -05:00
|
|
|
const parameters = res.consumed.length > 0 ?
|
|
|
|
{...posParams, ...res.consumed[res.consumed.length - 1].parameters} :
|
|
|
|
posParams;
|
2016-06-14 17:55:59 -04:00
|
|
|
|
2016-11-09 18:25:47 -05:00
|
|
|
return {consumedSegments: res.consumed, lastChild: res.consumed.length, parameters};
|
2016-05-23 19:14:23 -04:00
|
|
|
}
|
|
|
|
|
2016-06-14 17:55:59 -04:00
|
|
|
function checkOutletNameUniqueness(nodes: TreeNode<ActivatedRouteSnapshot>[]): void {
|
2016-06-15 19:45:19 -04:00
|
|
|
const names: {[k: string]: ActivatedRouteSnapshot} = {};
|
2016-06-14 17:55:59 -04:00
|
|
|
nodes.forEach(n => {
|
2016-11-12 08:08:58 -05:00
|
|
|
const routeWithSameOutletName = names[n.value.outlet];
|
2016-06-14 17:55:59 -04:00
|
|
|
if (routeWithSameOutletName) {
|
2016-06-15 19:45:19 -04:00
|
|
|
const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
|
2016-06-14 17:55:59 -04:00
|
|
|
const c = n.value.url.map(s => s.toString()).join('/');
|
|
|
|
throw new Error(`Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
|
|
|
|
}
|
|
|
|
names[n.value.outlet] = n.value;
|
|
|
|
});
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
2016-07-25 15:15:07 -04:00
|
|
|
function getSourceSegmentGroup(segmentGroup: UrlSegmentGroup): UrlSegmentGroup {
|
|
|
|
let s = segmentGroup;
|
2016-06-24 14:17:17 -04:00
|
|
|
while (s._sourceSegment) {
|
|
|
|
s = s._sourceSegment;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-07-25 15:15:07 -04:00
|
|
|
function getPathIndexShift(segmentGroup: UrlSegmentGroup): number {
|
|
|
|
let s = segmentGroup;
|
|
|
|
let res = (s._segmentIndexShift ? s._segmentIndexShift : 0);
|
2016-06-24 14:17:17 -04:00
|
|
|
while (s._sourceSegment) {
|
|
|
|
s = s._sourceSegment;
|
2016-07-25 15:15:07 -04:00
|
|
|
res += (s._segmentIndexShift ? s._segmentIndexShift : 0);
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
2016-07-18 17:53:13 -04:00
|
|
|
return res - 1;
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function split(
|
2016-07-25 15:15:07 -04:00
|
|
|
segmentGroup: UrlSegmentGroup, consumedSegments: UrlSegment[], slicedSegments: UrlSegment[],
|
2016-06-24 14:17:17 -04:00
|
|
|
config: Route[]) {
|
2016-07-25 15:15:07 -04:00
|
|
|
if (slicedSegments.length > 0 &&
|
|
|
|
containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
|
|
|
|
const s = new UrlSegmentGroup(
|
|
|
|
consumedSegments, createChildrenForEmptyPaths(
|
|
|
|
segmentGroup, consumedSegments, config,
|
|
|
|
new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
|
|
|
|
s._sourceSegment = segmentGroup;
|
|
|
|
s._segmentIndexShift = consumedSegments.length;
|
|
|
|
return {segmentGroup: s, slicedSegments: []};
|
2017-03-29 12:44:04 -04:00
|
|
|
}
|
2016-07-25 15:15:07 -04:00
|
|
|
|
2017-03-29 12:44:04 -04:00
|
|
|
if (slicedSegments.length === 0 &&
|
2016-07-25 15:15:07 -04:00
|
|
|
containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
|
|
|
|
const s = new UrlSegmentGroup(
|
|
|
|
segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(
|
|
|
|
segmentGroup, slicedSegments, config, segmentGroup.children));
|
|
|
|
s._sourceSegment = segmentGroup;
|
|
|
|
s._segmentIndexShift = consumedSegments.length;
|
|
|
|
return {segmentGroup: s, slicedSegments};
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
2017-03-29 12:44:04 -04:00
|
|
|
|
|
|
|
const s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
|
|
|
|
s._sourceSegment = segmentGroup;
|
|
|
|
s._segmentIndexShift = consumedSegments.length;
|
|
|
|
return {segmentGroup: s, slicedSegments};
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function addEmptyPathsToChildrenIfNeeded(
|
2016-07-25 15:15:07 -04:00
|
|
|
segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], routes: Route[],
|
|
|
|
children: {[name: string]: UrlSegmentGroup}): {[name: string]: UrlSegmentGroup} {
|
|
|
|
const res: {[name: string]: UrlSegmentGroup} = {};
|
2016-11-12 08:08:58 -05:00
|
|
|
for (const r of routes) {
|
2016-07-25 15:15:07 -04:00
|
|
|
if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
|
|
|
|
const s = new UrlSegmentGroup([], {});
|
|
|
|
s._sourceSegment = segmentGroup;
|
|
|
|
s._segmentIndexShift = segmentGroup.segments.length;
|
2016-06-24 14:17:17 -04:00
|
|
|
res[getOutlet(r)] = s;
|
|
|
|
}
|
|
|
|
}
|
2017-03-26 10:15:10 -04:00
|
|
|
return {...children, ...res};
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function createChildrenForEmptyPaths(
|
2016-07-25 15:15:07 -04:00
|
|
|
segmentGroup: UrlSegmentGroup, consumedSegments: UrlSegment[], routes: Route[],
|
|
|
|
primarySegment: UrlSegmentGroup): {[name: string]: UrlSegmentGroup} {
|
|
|
|
const res: {[name: string]: UrlSegmentGroup} = {};
|
2016-06-24 14:17:17 -04:00
|
|
|
res[PRIMARY_OUTLET] = primarySegment;
|
2016-07-25 15:15:07 -04:00
|
|
|
primarySegment._sourceSegment = segmentGroup;
|
|
|
|
primarySegment._segmentIndexShift = consumedSegments.length;
|
2016-06-24 14:17:17 -04:00
|
|
|
|
2016-11-12 08:08:58 -05:00
|
|
|
for (const r of routes) {
|
2016-07-22 21:32:26 -04:00
|
|
|
if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
|
2016-07-25 15:15:07 -04:00
|
|
|
const s = new UrlSegmentGroup([], {});
|
|
|
|
s._sourceSegment = segmentGroup;
|
|
|
|
s._segmentIndexShift = consumedSegments.length;
|
2016-06-24 14:17:17 -04:00
|
|
|
res[getOutlet(r)] = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
function containsEmptyPathMatchesWithNamedOutlets(
|
2016-07-25 15:15:07 -04:00
|
|
|
segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], routes: Route[]): boolean {
|
2017-03-29 12:44:04 -04:00
|
|
|
return routes.some(
|
|
|
|
r => emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet(r) !== PRIMARY_OUTLET);
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function containsEmptyPathMatches(
|
2016-07-25 15:15:07 -04:00
|
|
|
segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], routes: Route[]): boolean {
|
2017-03-29 12:44:04 -04:00
|
|
|
return routes.some(r => emptyPathMatch(segmentGroup, slicedSegments, r));
|
2016-06-24 14:17:17 -04:00
|
|
|
}
|
|
|
|
|
2016-07-25 15:15:07 -04:00
|
|
|
function emptyPathMatch(
|
|
|
|
segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], r: Route): boolean {
|
2017-03-29 12:44:04 -04:00
|
|
|
if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
|
2016-06-27 23:10:36 -04:00
|
|
|
return false;
|
2017-03-29 12:44:04 -04:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:17:17 -04:00
|
|
|
return r.path === '' && r.redirectTo === undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOutlet(route: Route): string {
|
2017-03-29 12:44:04 -04:00
|
|
|
return route.outlet || PRIMARY_OUTLET;
|
2016-06-27 17:00:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function getData(route: Route): Data {
|
2017-03-29 12:44:04 -04:00
|
|
|
return route.data || {};
|
2016-06-27 17:00:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function getResolve(route: Route): ResolveData {
|
2017-03-29 12:44:04 -04:00
|
|
|
return route.resolve || {};
|
2016-08-10 21:21:28 -04:00
|
|
|
}
|