@angular/router 5.2.4 → 5.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/router-testing.umd.js +2 -2
- package/bundles/router-testing.umd.min.js +2 -2
- package/bundles/router-testing.umd.min.js.map +1 -1
- package/bundles/router-upgrade.umd.js +2 -2
- package/bundles/router-upgrade.umd.min.js +2 -2
- package/bundles/router-upgrade.umd.min.js.map +1 -1
- package/bundles/router.umd.js +149 -76
- package/bundles/router.umd.js.map +1 -1
- package/bundles/router.umd.min.js +6 -6
- package/bundles/router.umd.min.js.map +1 -1
- package/esm2015/router.js +131 -74
- package/esm2015/router.js.map +1 -1
- package/esm2015/testing.js +1 -1
- package/esm2015/upgrade.js +1 -1
- package/esm5/router.js +148 -75
- package/esm5/router.js.map +1 -1
- package/esm5/testing.js +1 -1
- package/esm5/upgrade.js +1 -1
- package/package.json +4 -4
- package/router.metadata.json +1 -1
- package/src/config.d.ts +1 -0
- package/src/router.d.ts +5 -0
- package/src/url_tree.d.ts +14 -10
- package/testing.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/esm2015/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v5.2.
|
|
2
|
+
* @license Angular v5.2.8
|
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -672,6 +672,14 @@ function getFullPath(parentPath, currentRoute) {
|
|
|
672
672
|
return `${parentPath}/${currentRoute.path}`;
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* @param {?} r
|
|
677
|
+
* @return {?}
|
|
678
|
+
*/
|
|
679
|
+
function copyConfig(r) {
|
|
680
|
+
const /** @type {?} */ children = r.children && r.children.map(copyConfig);
|
|
681
|
+
return children ? Object.assign({}, r, { children }) : Object.assign({}, r);
|
|
682
|
+
}
|
|
675
683
|
|
|
676
684
|
/**
|
|
677
685
|
* @fileoverview added by tsickle
|
|
@@ -1148,7 +1156,7 @@ class DefaultUrlSerializer {
|
|
|
1148
1156
|
serialize(tree) {
|
|
1149
1157
|
const /** @type {?} */ segment = `/${serializeSegment(tree.root, true)}`;
|
|
1150
1158
|
const /** @type {?} */ query = serializeQueryParams(tree.queryParams);
|
|
1151
|
-
const /** @type {?} */ fragment = typeof tree.fragment === `string` ? `#${
|
|
1159
|
+
const /** @type {?} */ fragment = typeof tree.fragment === `string` ? `#${encodeUriQuery((/** @type {?} */ ((tree.fragment))))}` : '';
|
|
1152
1160
|
return `${segment}${query}${fragment}`;
|
|
1153
1161
|
}
|
|
1154
1162
|
}
|
|
@@ -1192,9 +1200,10 @@ function serializeSegment(segment, root) {
|
|
|
1192
1200
|
}
|
|
1193
1201
|
}
|
|
1194
1202
|
/**
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1203
|
+
* Encodes a URI string with the default encoding. This function will only ever be called from
|
|
1204
|
+
* `encodeUriQuery` or `encodeUriSegment` as it's the base set of encodings to be used. We need
|
|
1205
|
+
* a custom encoding because encodeURIComponent is too aggressive and encodes stuff that doesn't
|
|
1206
|
+
* have to be encoded per http://tools.ietf.org/html/rfc3986:
|
|
1198
1207
|
* query = *( pchar / "/" / "?" )
|
|
1199
1208
|
* pchar = unreserved / pct-encoded / sub-delims / ":" / "\@"
|
|
1200
1209
|
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
|
@@ -1204,13 +1213,35 @@ function serializeSegment(segment, root) {
|
|
|
1204
1213
|
* @param {?} s
|
|
1205
1214
|
* @return {?}
|
|
1206
1215
|
*/
|
|
1207
|
-
function
|
|
1216
|
+
function encodeUriString(s) {
|
|
1208
1217
|
return encodeURIComponent(s)
|
|
1209
1218
|
.replace(/%40/g, '@')
|
|
1210
1219
|
.replace(/%3A/gi, ':')
|
|
1211
1220
|
.replace(/%24/g, '$')
|
|
1212
|
-
.replace(/%2C/gi, ',')
|
|
1213
|
-
|
|
1221
|
+
.replace(/%2C/gi, ',');
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* This function should be used to encode both keys and values in a query string key/value or the
|
|
1225
|
+
* URL fragment. In the following URL, you need to call encodeUriQuery on "k", "v" and "f":
|
|
1226
|
+
*
|
|
1227
|
+
* http://www.site.org/html;mk=mv?k=v#f
|
|
1228
|
+
* @param {?} s
|
|
1229
|
+
* @return {?}
|
|
1230
|
+
*/
|
|
1231
|
+
function encodeUriQuery(s) {
|
|
1232
|
+
return encodeUriString(s).replace(/%3B/gi, ';');
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* This function should be run on any URI segment as well as the key and value in a key/value
|
|
1236
|
+
* pair for matrix params. In the following URL, you need to call encodeUriSegment on "html",
|
|
1237
|
+
* "mk", and "mv":
|
|
1238
|
+
*
|
|
1239
|
+
* http://www.site.org/html;mk=mv?k=v#f
|
|
1240
|
+
* @param {?} s
|
|
1241
|
+
* @return {?}
|
|
1242
|
+
*/
|
|
1243
|
+
function encodeUriSegment(s) {
|
|
1244
|
+
return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
|
|
1214
1245
|
}
|
|
1215
1246
|
/**
|
|
1216
1247
|
* @param {?} s
|
|
@@ -1219,19 +1250,28 @@ function encode(s) {
|
|
|
1219
1250
|
function decode(s) {
|
|
1220
1251
|
return decodeURIComponent(s);
|
|
1221
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* @param {?} s
|
|
1255
|
+
* @return {?}
|
|
1256
|
+
*/
|
|
1257
|
+
function decodeQuery(s) {
|
|
1258
|
+
return decode(s.replace(/\+/g, '%20'));
|
|
1259
|
+
}
|
|
1222
1260
|
/**
|
|
1223
1261
|
* @param {?} path
|
|
1224
1262
|
* @return {?}
|
|
1225
1263
|
*/
|
|
1226
1264
|
function serializePath(path) {
|
|
1227
|
-
return `${
|
|
1265
|
+
return `${encodeUriSegment(path.path)}${serializeMatrixParams(path.parameters)}`;
|
|
1228
1266
|
}
|
|
1229
1267
|
/**
|
|
1230
1268
|
* @param {?} params
|
|
1231
1269
|
* @return {?}
|
|
1232
1270
|
*/
|
|
1233
|
-
function
|
|
1234
|
-
return Object.keys(params)
|
|
1271
|
+
function serializeMatrixParams(params) {
|
|
1272
|
+
return Object.keys(params)
|
|
1273
|
+
.map(key => `;${encodeUriSegment(key)}=${encodeUriSegment(params[key])}`)
|
|
1274
|
+
.join('');
|
|
1235
1275
|
}
|
|
1236
1276
|
/**
|
|
1237
1277
|
* @param {?} params
|
|
@@ -1240,8 +1280,9 @@ function serializeParams(params) {
|
|
|
1240
1280
|
function serializeQueryParams(params) {
|
|
1241
1281
|
const /** @type {?} */ strParams = Object.keys(params).map((name) => {
|
|
1242
1282
|
const /** @type {?} */ value = params[name];
|
|
1243
|
-
return Array.isArray(value) ?
|
|
1244
|
-
`${
|
|
1283
|
+
return Array.isArray(value) ?
|
|
1284
|
+
value.map(v => `${encodeUriQuery(name)}=${encodeUriQuery(v)}`).join('&') :
|
|
1285
|
+
`${encodeUriQuery(name)}=${encodeUriQuery(value)}`;
|
|
1245
1286
|
});
|
|
1246
1287
|
return strParams.length ? `?${strParams.join("&")}` : '';
|
|
1247
1288
|
}
|
|
@@ -1307,7 +1348,7 @@ class UrlParser {
|
|
|
1307
1348
|
* @return {?}
|
|
1308
1349
|
*/
|
|
1309
1350
|
parseFragment() {
|
|
1310
|
-
return this.consumeOptional('#') ?
|
|
1351
|
+
return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
|
|
1311
1352
|
}
|
|
1312
1353
|
/**
|
|
1313
1354
|
* @return {?}
|
|
@@ -1398,8 +1439,8 @@ class UrlParser {
|
|
|
1398
1439
|
this.capture(value);
|
|
1399
1440
|
}
|
|
1400
1441
|
}
|
|
1401
|
-
const /** @type {?} */ decodedKey =
|
|
1402
|
-
const /** @type {?} */ decodedVal =
|
|
1442
|
+
const /** @type {?} */ decodedKey = decodeQuery(key);
|
|
1443
|
+
const /** @type {?} */ decodedVal = decodeQuery(value);
|
|
1403
1444
|
if (params.hasOwnProperty(decodedKey)) {
|
|
1404
1445
|
// Append to existing values
|
|
1405
1446
|
let /** @type {?} */ currentVal = params[decodedKey];
|
|
@@ -3968,7 +4009,7 @@ class RouterConfigLoader {
|
|
|
3968
4009
|
this.onLoadEndListener(route);
|
|
3969
4010
|
}
|
|
3970
4011
|
const /** @type {?} */ module = factory.create(parentInjector);
|
|
3971
|
-
return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)), module);
|
|
4012
|
+
return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(copyConfig), module);
|
|
3972
4013
|
});
|
|
3973
4014
|
}
|
|
3974
4015
|
/**
|
|
@@ -4213,7 +4254,7 @@ class Router {
|
|
|
4213
4254
|
*/
|
|
4214
4255
|
resetConfig(config) {
|
|
4215
4256
|
validateConfig(config);
|
|
4216
|
-
this.config = config;
|
|
4257
|
+
this.config = config.map(copyConfig);
|
|
4217
4258
|
this.navigated = false;
|
|
4218
4259
|
}
|
|
4219
4260
|
/**
|
|
@@ -4565,66 +4606,82 @@ class Router {
|
|
|
4565
4606
|
return { appliedUrl, state: null, shouldActivate };
|
|
4566
4607
|
}
|
|
4567
4608
|
});
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
navigationIsSuccessful =
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4609
|
+
this.activateRoutes(routerState$, this.routerState, this.currentUrlTree, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise);
|
|
4610
|
+
});
|
|
4611
|
+
}
|
|
4612
|
+
/**
|
|
4613
|
+
* Performs the logic of activating routes. This is a synchronous process by default. While this
|
|
4614
|
+
* is a private method, it could be overridden to make activation asynchronous.
|
|
4615
|
+
* @param {?} state
|
|
4616
|
+
* @param {?} storedState
|
|
4617
|
+
* @param {?} storedUrl
|
|
4618
|
+
* @param {?} id
|
|
4619
|
+
* @param {?} url
|
|
4620
|
+
* @param {?} rawUrl
|
|
4621
|
+
* @param {?} skipLocationChange
|
|
4622
|
+
* @param {?} replaceUrl
|
|
4623
|
+
* @param {?} resolvePromise
|
|
4624
|
+
* @param {?} rejectPromise
|
|
4625
|
+
* @return {?}
|
|
4626
|
+
*/
|
|
4627
|
+
activateRoutes(state, storedState, storedUrl, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise) {
|
|
4628
|
+
// applied the new router state
|
|
4629
|
+
// this operation has side effects
|
|
4630
|
+
let /** @type {?} */ navigationIsSuccessful;
|
|
4631
|
+
state
|
|
4632
|
+
.forEach(({ appliedUrl, state, shouldActivate }) => {
|
|
4633
|
+
if (!shouldActivate || id !== this.navigationId) {
|
|
4634
|
+
navigationIsSuccessful = false;
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
this.currentUrlTree = appliedUrl;
|
|
4638
|
+
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
|
|
4639
|
+
(/** @type {?} */ (this)).routerState = state;
|
|
4640
|
+
if (!skipLocationChange) {
|
|
4641
|
+
const /** @type {?} */ path = this.urlSerializer.serialize(this.rawUrlTree);
|
|
4642
|
+
if (this.location.isCurrentPathEqualTo(path) || replaceUrl) {
|
|
4643
|
+
this.location.replaceState(path);
|
|
4601
4644
|
}
|
|
4602
4645
|
else {
|
|
4603
|
-
this.
|
|
4604
|
-
(/** @type {?} */ (this.events))
|
|
4605
|
-
.next(new NavigationCancel(id, this.serializeUrl(url), ''));
|
|
4606
|
-
resolvePromise(false);
|
|
4646
|
+
this.location.go(path);
|
|
4607
4647
|
}
|
|
4608
|
-
}
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4648
|
+
}
|
|
4649
|
+
new ActivateRoutes(this.routeReuseStrategy, state, storedState, (evt) => this.triggerEvent(evt))
|
|
4650
|
+
.activate(this.rootContexts);
|
|
4651
|
+
navigationIsSuccessful = true;
|
|
4652
|
+
})
|
|
4653
|
+
.then(() => {
|
|
4654
|
+
if (navigationIsSuccessful) {
|
|
4655
|
+
this.navigated = true;
|
|
4656
|
+
(/** @type {?} */ (this.events))
|
|
4657
|
+
.next(new NavigationEnd(id, this.serializeUrl(url), this.serializeUrl(this.currentUrlTree)));
|
|
4658
|
+
resolvePromise(true);
|
|
4659
|
+
}
|
|
4660
|
+
else {
|
|
4661
|
+
this.resetUrlToCurrentUrlTree();
|
|
4662
|
+
(/** @type {?} */ (this.events))
|
|
4663
|
+
.next(new NavigationCancel(id, this.serializeUrl(url), ''));
|
|
4664
|
+
resolvePromise(false);
|
|
4665
|
+
}
|
|
4666
|
+
}, (e) => {
|
|
4667
|
+
if (isNavigationCancelingError(e)) {
|
|
4668
|
+
this.navigated = true;
|
|
4669
|
+
this.resetStateAndUrl(storedState, storedUrl, rawUrl);
|
|
4670
|
+
(/** @type {?} */ (this.events))
|
|
4671
|
+
.next(new NavigationCancel(id, this.serializeUrl(url), e.message));
|
|
4672
|
+
resolvePromise(false);
|
|
4673
|
+
}
|
|
4674
|
+
else {
|
|
4675
|
+
this.resetStateAndUrl(storedState, storedUrl, rawUrl);
|
|
4676
|
+
(/** @type {?} */ (this.events))
|
|
4677
|
+
.next(new NavigationError(id, this.serializeUrl(url), e));
|
|
4678
|
+
try {
|
|
4679
|
+
resolvePromise(this.errorHandler(e));
|
|
4615
4680
|
}
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
(/** @type {?} */ (this.events))
|
|
4619
|
-
.next(new NavigationError(id, this.serializeUrl(url), e));
|
|
4620
|
-
try {
|
|
4621
|
-
resolvePromise(this.errorHandler(e));
|
|
4622
|
-
}
|
|
4623
|
-
catch (/** @type {?} */ ee) {
|
|
4624
|
-
rejectPromise(ee);
|
|
4625
|
-
}
|
|
4681
|
+
catch (/** @type {?} */ ee) {
|
|
4682
|
+
rejectPromise(ee);
|
|
4626
4683
|
}
|
|
4627
|
-
}
|
|
4684
|
+
}
|
|
4628
4685
|
});
|
|
4629
4686
|
}
|
|
4630
4687
|
/**
|
|
@@ -6233,7 +6290,7 @@ function provideRouterInitializer() {
|
|
|
6233
6290
|
/**
|
|
6234
6291
|
* \@stable
|
|
6235
6292
|
*/
|
|
6236
|
-
const VERSION = new Version('5.2.
|
|
6293
|
+
const VERSION = new Version('5.2.8');
|
|
6237
6294
|
|
|
6238
6295
|
/**
|
|
6239
6296
|
* @fileoverview added by tsickle
|