source: trip-planner-front/node_modules/@angular/router/esm2015/src/utils/config.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 18.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { EmptyOutletComponent } from '../components/empty_outlet';
9import { PRIMARY_OUTLET } from '../shared';
10export function validateConfig(config, parentPath = '') {
11 // forEach doesn't iterate undefined values
12 for (let i = 0; i < config.length; i++) {
13 const route = config[i];
14 const fullPath = getFullPath(parentPath, route);
15 validateNode(route, fullPath);
16 }
17}
18function validateNode(route, fullPath) {
19 if (typeof ngDevMode === 'undefined' || ngDevMode) {
20 if (!route) {
21 throw new Error(`
22 Invalid configuration of route '${fullPath}': Encountered undefined route.
23 The reason might be an extra comma.
24
25 Example:
26 const routes: Routes = [
27 { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
28 { path: 'dashboard', component: DashboardComponent },, << two commas
29 { path: 'detail/:id', component: HeroDetailComponent }
30 ];
31 `);
32 }
33 if (Array.isArray(route)) {
34 throw new Error(`Invalid configuration of route '${fullPath}': Array cannot be specified`);
35 }
36 if (!route.component && !route.children && !route.loadChildren &&
37 (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
38 throw new Error(`Invalid configuration of route '${fullPath}': a componentless route without children or loadChildren cannot have a named outlet set`);
39 }
40 if (route.redirectTo && route.children) {
41 throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and children cannot be used together`);
42 }
43 if (route.redirectTo && route.loadChildren) {
44 throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and loadChildren cannot be used together`);
45 }
46 if (route.children && route.loadChildren) {
47 throw new Error(`Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`);
48 }
49 if (route.redirectTo && route.component) {
50 throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and component cannot be used together`);
51 }
52 if (route.redirectTo && route.canActivate) {
53 throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and canActivate cannot be used together. Redirects happen before activation ` +
54 `so canActivate will never be executed.`);
55 }
56 if (route.path && route.matcher) {
57 throw new Error(`Invalid configuration of route '${fullPath}': path and matcher cannot be used together`);
58 }
59 if (route.redirectTo === void 0 && !route.component && !route.children && !route.loadChildren) {
60 throw new Error(`Invalid configuration of route '${fullPath}'. One of the following must be provided: component, redirectTo, children or loadChildren`);
61 }
62 if (route.path === void 0 && route.matcher === void 0) {
63 throw new Error(`Invalid configuration of route '${fullPath}': routes must have either a path or a matcher specified`);
64 }
65 if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
66 throw new Error(`Invalid configuration of route '${fullPath}': path cannot start with a slash`);
67 }
68 if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
69 const exp = `The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.`;
70 throw new Error(`Invalid configuration of route '{path: "${fullPath}", redirectTo: "${route.redirectTo}"}': please provide 'pathMatch'. ${exp}`);
71 }
72 if (route.pathMatch !== void 0 && route.pathMatch !== 'full' && route.pathMatch !== 'prefix') {
73 throw new Error(`Invalid configuration of route '${fullPath}': pathMatch can only be set to 'prefix' or 'full'`);
74 }
75 }
76 if (route.children) {
77 validateConfig(route.children, fullPath);
78 }
79}
80function getFullPath(parentPath, currentRoute) {
81 if (!currentRoute) {
82 return parentPath;
83 }
84 if (!parentPath && !currentRoute.path) {
85 return '';
86 }
87 else if (parentPath && !currentRoute.path) {
88 return `${parentPath}/`;
89 }
90 else if (!parentPath && currentRoute.path) {
91 return currentRoute.path;
92 }
93 else {
94 return `${parentPath}/${currentRoute.path}`;
95 }
96}
97/**
98 * Makes a copy of the config and adds any default required properties.
99 */
100export function standardizeConfig(r) {
101 const children = r.children && r.children.map(standardizeConfig);
102 const c = children ? Object.assign(Object.assign({}, r), { children }) : Object.assign({}, r);
103 if (!c.component && (children || c.loadChildren) && (c.outlet && c.outlet !== PRIMARY_OUTLET)) {
104 c.component = EmptyOutletComponent;
105 }
106 return c;
107}
108/** Returns the `route.outlet` or PRIMARY_OUTLET if none exists. */
109export function getOutlet(route) {
110 return route.outlet || PRIMARY_OUTLET;
111}
112/**
113 * Sorts the `routes` such that the ones with an outlet matching `outletName` come first.
114 * The order of the configs is otherwise preserved.
115 */
116export function sortByMatchingOutlets(routes, outletName) {
117 const sortedConfig = routes.filter(r => getOutlet(r) === outletName);
118 sortedConfig.push(...routes.filter(r => getOutlet(r) !== outletName));
119 return sortedConfig;
120}
121//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvcm91dGVyL3NyYy91dGlscy9jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLG9CQUFvQixFQUFDLE1BQU0sNEJBQTRCLENBQUM7QUFFaEUsT0FBTyxFQUFDLGNBQWMsRUFBQyxNQUFNLFdBQVcsQ0FBQztBQUV6QyxNQUFNLFVBQVUsY0FBYyxDQUFDLE1BQWMsRUFBRSxhQUFxQixFQUFFO0lBQ3BFLDJDQUEyQztJQUMzQyxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsTUFBTSxDQUFDLE1BQU0sRUFBRSxDQUFDLEVBQUUsRUFBRTtRQUN0QyxNQUFNLEtBQUssR0FBVSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDL0IsTUFBTSxRQUFRLEdBQVcsV0FBVyxDQUFDLFVBQVUsRUFBRSxLQUFLLENBQUMsQ0FBQztRQUN4RCxZQUFZLENBQUMsS0FBSyxFQUFFLFFBQVEsQ0FBQyxDQUFDO0tBQy9CO0FBQ0gsQ0FBQztBQ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G9yZGVyIG9mIHRoZSBjb25maWdzIGlzIG90aGVyd2lzZSBwcmVzZXJ2ZWQuXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBzb3J0QnlNYXRjaGluZ091dGxldHMocm91dGVzOiBSb3V0ZXMsIG91dGxldE5hbWU6IHN0cmluZyk6IFJvdXRlcyB7XG4gIGNvbnN0IHNvcnRlZENvbmZpZyA9IHJvdXRlcy5maWx0ZXIociA9PiBnZXRPdXRsZXQocikgPT09IG91dGxldE5hbWUpO1xuICBzb3J0ZWRDb25maWcucHVzaCguLi5yb3V0ZXMuZmlsdGVyKHIgPT4gZ2V0T3V0bGV0KHIpICE9PSBvdXRsZXROYW1lKSk7XG4gIHJldHVybiBzb3J0ZWRDb25maWc7XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.