@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v5.2.4
2
+ * @license Angular v5.2.8
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v5.2.4
2
+ * @license Angular v5.2.8
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/esm5/router.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v5.2.4
2
+ * @license Angular v5.2.8
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -700,6 +700,14 @@ function getFullPath(parentPath, currentRoute) {
700
700
  return parentPath + "/" + currentRoute.path;
701
701
  }
702
702
  }
703
+ /**
704
+ * @param {?} r
705
+ * @return {?}
706
+ */
707
+ function copyConfig(r) {
708
+ var /** @type {?} */ children = r.children && r.children.map(copyConfig);
709
+ return children ? __assign({}, r, { children: children }) : __assign({}, r);
710
+ }
703
711
 
704
712
  /**
705
713
  * @fileoverview added by tsickle
@@ -1217,7 +1225,7 @@ var DefaultUrlSerializer = /** @class */ (function () {
1217
1225
  function (tree) {
1218
1226
  var /** @type {?} */ segment = "/" + serializeSegment(tree.root, true);
1219
1227
  var /** @type {?} */ query = serializeQueryParams(tree.queryParams);
1220
- var /** @type {?} */ fragment = typeof tree.fragment === "string" ? "#" + encodeURI((/** @type {?} */ ((tree.fragment)))) : '';
1228
+ var /** @type {?} */ fragment = typeof tree.fragment === "string" ? "#" + encodeUriQuery((/** @type {?} */ ((tree.fragment)))) : '';
1221
1229
  return "" + segment + query + fragment;
1222
1230
  };
1223
1231
  return DefaultUrlSerializer;
@@ -1262,9 +1270,10 @@ function serializeSegment(segment, root) {
1262
1270
  }
1263
1271
  }
1264
1272
  /**
1265
- * This method is intended for encoding *key* or *value* parts of query component. We need a custom
1266
- * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be
1267
- * encoded per http://tools.ietf.org/html/rfc3986:
1273
+ * Encodes a URI string with the default encoding. This function will only ever be called from
1274
+ * `encodeUriQuery` or `encodeUriSegment` as it's the base set of encodings to be used. We need
1275
+ * a custom encoding because encodeURIComponent is too aggressive and encodes stuff that doesn't
1276
+ * have to be encoded per http://tools.ietf.org/html/rfc3986:
1268
1277
  * query = *( pchar / "/" / "?" )
1269
1278
  * pchar = unreserved / pct-encoded / sub-delims / ":" / "\@"
1270
1279
  * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
@@ -1274,13 +1283,35 @@ function serializeSegment(segment, root) {
1274
1283
  * @param {?} s
1275
1284
  * @return {?}
1276
1285
  */
1277
- function encode(s) {
1286
+ function encodeUriString(s) {
1278
1287
  return encodeURIComponent(s)
1279
1288
  .replace(/%40/g, '@')
1280
1289
  .replace(/%3A/gi, ':')
1281
1290
  .replace(/%24/g, '$')
1282
- .replace(/%2C/gi, ',')
1283
- .replace(/%3B/gi, ';');
1291
+ .replace(/%2C/gi, ',');
1292
+ }
1293
+ /**
1294
+ * This function should be used to encode both keys and values in a query string key/value or the
1295
+ * URL fragment. In the following URL, you need to call encodeUriQuery on "k", "v" and "f":
1296
+ *
1297
+ * http://www.site.org/html;mk=mv?k=v#f
1298
+ * @param {?} s
1299
+ * @return {?}
1300
+ */
1301
+ function encodeUriQuery(s) {
1302
+ return encodeUriString(s).replace(/%3B/gi, ';');
1303
+ }
1304
+ /**
1305
+ * This function should be run on any URI segment as well as the key and value in a key/value
1306
+ * pair for matrix params. In the following URL, you need to call encodeUriSegment on "html",
1307
+ * "mk", and "mv":
1308
+ *
1309
+ * http://www.site.org/html;mk=mv?k=v#f
1310
+ * @param {?} s
1311
+ * @return {?}
1312
+ */
1313
+ function encodeUriSegment(s) {
1314
+ return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
1284
1315
  }
1285
1316
  /**
1286
1317
  * @param {?} s
@@ -1289,19 +1320,28 @@ function encode(s) {
1289
1320
  function decode(s) {
1290
1321
  return decodeURIComponent(s);
1291
1322
  }
1323
+ /**
1324
+ * @param {?} s
1325
+ * @return {?}
1326
+ */
1327
+ function decodeQuery(s) {
1328
+ return decode(s.replace(/\+/g, '%20'));
1329
+ }
1292
1330
  /**
1293
1331
  * @param {?} path
1294
1332
  * @return {?}
1295
1333
  */
1296
1334
  function serializePath(path) {
1297
- return "" + encode(path.path) + serializeParams(path.parameters);
1335
+ return "" + encodeUriSegment(path.path) + serializeMatrixParams(path.parameters);
1298
1336
  }
1299
1337
  /**
1300
1338
  * @param {?} params
1301
1339
  * @return {?}
1302
1340
  */
1303
- function serializeParams(params) {
1304
- return Object.keys(params).map(function (key) { return ";" + encode(key) + "=" + encode(params[key]); }).join('');
1341
+ function serializeMatrixParams(params) {
1342
+ return Object.keys(params)
1343
+ .map(function (key) { return ";" + encodeUriSegment(key) + "=" + encodeUriSegment(params[key]); })
1344
+ .join('');
1305
1345
  }
1306
1346
  /**
1307
1347
  * @param {?} params
@@ -1310,8 +1350,9 @@ function serializeParams(params) {
1310
1350
  function serializeQueryParams(params) {
1311
1351
  var /** @type {?} */ strParams = Object.keys(params).map(function (name) {
1312
1352
  var /** @type {?} */ value = params[name];
1313
- return Array.isArray(value) ? value.map(function (v) { return encode(name) + "=" + encode(v); }).join('&') :
1314
- encode(name) + "=" + encode(value);
1353
+ return Array.isArray(value) ?
1354
+ value.map(function (v) { return encodeUriQuery(name) + "=" + encodeUriQuery(v); }).join('&') :
1355
+ encodeUriQuery(name) + "=" + encodeUriQuery(value);
1315
1356
  });
1316
1357
  return strParams.length ? "?" + strParams.join("&") : '';
1317
1358
  }
@@ -1383,7 +1424,7 @@ var UrlParser = /** @class */ (function () {
1383
1424
  * @return {?}
1384
1425
  */
1385
1426
  function () {
1386
- return this.consumeOptional('#') ? decodeURI(this.remaining) : null;
1427
+ return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
1387
1428
  };
1388
1429
  /**
1389
1430
  * @return {?}
@@ -1491,8 +1532,8 @@ var UrlParser = /** @class */ (function () {
1491
1532
  this.capture(value);
1492
1533
  }
1493
1534
  }
1494
- var /** @type {?} */ decodedKey = decode(key);
1495
- var /** @type {?} */ decodedVal = decode(value);
1535
+ var /** @type {?} */ decodedKey = decodeQuery(key);
1536
+ var /** @type {?} */ decodedVal = decodeQuery(value);
1496
1537
  if (params.hasOwnProperty(decodedKey)) {
1497
1538
  // Append to existing values
1498
1539
  var /** @type {?} */ currentVal = params[decodedKey];
@@ -4526,7 +4567,7 @@ var RouterConfigLoader = /** @class */ (function () {
4526
4567
  _this.onLoadEndListener(route);
4527
4568
  }
4528
4569
  var /** @type {?} */ module = factory.create(parentInjector);
4529
- return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)), module);
4570
+ return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(copyConfig), module);
4530
4571
  });
4531
4572
  };
4532
4573
  /**
@@ -4856,7 +4897,7 @@ var Router = /** @class */ (function () {
4856
4897
  */
4857
4898
  function (config) {
4858
4899
  validateConfig(config);
4859
- this.config = config;
4900
+ this.config = config.map(copyConfig);
4860
4901
  this.navigated = false;
4861
4902
  };
4862
4903
  /** @docsNotRequired */
@@ -5450,67 +5491,99 @@ var Router = /** @class */ (function () {
5450
5491
  return { appliedUrl: appliedUrl, state: null, shouldActivate: shouldActivate };
5451
5492
  }
5452
5493
  });
5453
- // applied the new router state
5454
- // this operation has side effects
5455
- var /** @type {?} */ navigationIsSuccessful;
5456
- var /** @type {?} */ storedState = _this.routerState;
5457
- var /** @type {?} */ storedUrl = _this.currentUrlTree;
5458
- routerState$
5459
- .forEach(function (_a) {
5460
- var appliedUrl = _a.appliedUrl, state = _a.state, shouldActivate = _a.shouldActivate;
5461
- if (!shouldActivate || id !== _this.navigationId) {
5462
- navigationIsSuccessful = false;
5463
- return;
5464
- }
5465
- _this.currentUrlTree = appliedUrl;
5466
- _this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, rawUrl);
5467
- (/** @type {?} */ (_this)).routerState = state;
5468
- if (!skipLocationChange) {
5469
- var /** @type {?} */ path = _this.urlSerializer.serialize(_this.rawUrlTree);
5470
- if (_this.location.isCurrentPathEqualTo(path) || replaceUrl) {
5471
- _this.location.replaceState(path);
5472
- }
5473
- else {
5474
- _this.location.go(path);
5475
- }
5476
- }
5477
- new ActivateRoutes(_this.routeReuseStrategy, state, storedState, function (evt) { return _this.triggerEvent(evt); })
5478
- .activate(_this.rootContexts);
5479
- navigationIsSuccessful = true;
5480
- })
5481
- .then(function () {
5482
- if (navigationIsSuccessful) {
5483
- _this.navigated = true;
5484
- (/** @type {?} */ (_this.events))
5485
- .next(new NavigationEnd(id, _this.serializeUrl(url), _this.serializeUrl(_this.currentUrlTree)));
5486
- resolvePromise(true);
5494
+ _this.activateRoutes(routerState$, _this.routerState, _this.currentUrlTree, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise);
5495
+ });
5496
+ };
5497
+ /**
5498
+ * Performs the logic of activating routes. This is a synchronous process by default. While this
5499
+ * is a private method, it could be overridden to make activation asynchronous.
5500
+ * @param {?} state
5501
+ * @param {?} storedState
5502
+ * @param {?} storedUrl
5503
+ * @param {?} id
5504
+ * @param {?} url
5505
+ * @param {?} rawUrl
5506
+ * @param {?} skipLocationChange
5507
+ * @param {?} replaceUrl
5508
+ * @param {?} resolvePromise
5509
+ * @param {?} rejectPromise
5510
+ * @return {?}
5511
+ */
5512
+ Router.prototype.activateRoutes = /**
5513
+ * Performs the logic of activating routes. This is a synchronous process by default. While this
5514
+ * is a private method, it could be overridden to make activation asynchronous.
5515
+ * @param {?} state
5516
+ * @param {?} storedState
5517
+ * @param {?} storedUrl
5518
+ * @param {?} id
5519
+ * @param {?} url
5520
+ * @param {?} rawUrl
5521
+ * @param {?} skipLocationChange
5522
+ * @param {?} replaceUrl
5523
+ * @param {?} resolvePromise
5524
+ * @param {?} rejectPromise
5525
+ * @return {?}
5526
+ */
5527
+ function (state, storedState, storedUrl, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise) {
5528
+ var _this = this;
5529
+ // applied the new router state
5530
+ // this operation has side effects
5531
+ var /** @type {?} */ navigationIsSuccessful;
5532
+ state
5533
+ .forEach(function (_a) {
5534
+ var appliedUrl = _a.appliedUrl, state = _a.state, shouldActivate = _a.shouldActivate;
5535
+ if (!shouldActivate || id !== _this.navigationId) {
5536
+ navigationIsSuccessful = false;
5537
+ return;
5538
+ }
5539
+ _this.currentUrlTree = appliedUrl;
5540
+ _this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, rawUrl);
5541
+ (/** @type {?} */ (_this)).routerState = state;
5542
+ if (!skipLocationChange) {
5543
+ var /** @type {?} */ path = _this.urlSerializer.serialize(_this.rawUrlTree);
5544
+ if (_this.location.isCurrentPathEqualTo(path) || replaceUrl) {
5545
+ _this.location.replaceState(path);
5487
5546
  }
5488
5547
  else {
5489
- _this.resetUrlToCurrentUrlTree();
5490
- (/** @type {?} */ (_this.events))
5491
- .next(new NavigationCancel(id, _this.serializeUrl(url), ''));
5492
- resolvePromise(false);
5548
+ _this.location.go(path);
5493
5549
  }
5494
- }, function (e) {
5495
- if (isNavigationCancelingError(e)) {
5496
- _this.navigated = true;
5497
- _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
5498
- (/** @type {?} */ (_this.events))
5499
- .next(new NavigationCancel(id, _this.serializeUrl(url), e.message));
5500
- resolvePromise(false);
5550
+ }
5551
+ new ActivateRoutes(_this.routeReuseStrategy, state, storedState, function (evt) { return _this.triggerEvent(evt); })
5552
+ .activate(_this.rootContexts);
5553
+ navigationIsSuccessful = true;
5554
+ })
5555
+ .then(function () {
5556
+ if (navigationIsSuccessful) {
5557
+ _this.navigated = true;
5558
+ (/** @type {?} */ (_this.events))
5559
+ .next(new NavigationEnd(id, _this.serializeUrl(url), _this.serializeUrl(_this.currentUrlTree)));
5560
+ resolvePromise(true);
5561
+ }
5562
+ else {
5563
+ _this.resetUrlToCurrentUrlTree();
5564
+ (/** @type {?} */ (_this.events))
5565
+ .next(new NavigationCancel(id, _this.serializeUrl(url), ''));
5566
+ resolvePromise(false);
5567
+ }
5568
+ }, function (e) {
5569
+ if (isNavigationCancelingError(e)) {
5570
+ _this.navigated = true;
5571
+ _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
5572
+ (/** @type {?} */ (_this.events))
5573
+ .next(new NavigationCancel(id, _this.serializeUrl(url), e.message));
5574
+ resolvePromise(false);
5575
+ }
5576
+ else {
5577
+ _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
5578
+ (/** @type {?} */ (_this.events))
5579
+ .next(new NavigationError(id, _this.serializeUrl(url), e));
5580
+ try {
5581
+ resolvePromise(_this.errorHandler(e));
5501
5582
  }
5502
- else {
5503
- _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
5504
- (/** @type {?} */ (_this.events))
5505
- .next(new NavigationError(id, _this.serializeUrl(url), e));
5506
- try {
5507
- resolvePromise(_this.errorHandler(e));
5508
- }
5509
- catch (/** @type {?} */ ee) {
5510
- rejectPromise(ee);
5511
- }
5583
+ catch (/** @type {?} */ ee) {
5584
+ rejectPromise(ee);
5512
5585
  }
5513
- });
5586
+ }
5514
5587
  });
5515
5588
  };
5516
5589
  /**
@@ -7405,7 +7478,7 @@ function provideRouterInitializer() {
7405
7478
  /**
7406
7479
  * \@stable
7407
7480
  */
7408
- var VERSION = new Version('5.2.4');
7481
+ var VERSION = new Version('5.2.8');
7409
7482
 
7410
7483
  /**
7411
7484
  * @fileoverview added by tsickle