@angular/router 5.2.7 → 5.2.11

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/esm2015/router.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v5.2.7
2
+ * @license Angular v5.2.11
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1156,7 +1156,7 @@ class DefaultUrlSerializer {
1156
1156
  serialize(tree) {
1157
1157
  const /** @type {?} */ segment = `/${serializeSegment(tree.root, true)}`;
1158
1158
  const /** @type {?} */ query = serializeQueryParams(tree.queryParams);
1159
- const /** @type {?} */ fragment = typeof tree.fragment === `string` ? `#${encodeURI((/** @type {?} */ ((tree.fragment))))}` : '';
1159
+ const /** @type {?} */ fragment = typeof tree.fragment === `string` ? `#${encodeUriFragment((/** @type {?} */ ((tree.fragment))))}` : '';
1160
1160
  return `${segment}${query}${fragment}`;
1161
1161
  }
1162
1162
  }
@@ -1200,25 +1200,53 @@ function serializeSegment(segment, root) {
1200
1200
  }
1201
1201
  }
1202
1202
  /**
1203
- * This method is intended for encoding *key* or *value* parts of query component. We need a custom
1204
- * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be
1205
- * encoded per http://tools.ietf.org/html/rfc3986:
1206
- * query = *( pchar / "/" / "?" )
1207
- * pchar = unreserved / pct-encoded / sub-delims / ":" / "\@"
1208
- * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
1209
- * pct-encoded = "%" HEXDIG HEXDIG
1210
- * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
1211
- * / "*" / "+" / "," / ";" / "="
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 https://url.spec.whatwg.org.
1212
1207
  * @param {?} s
1213
1208
  * @return {?}
1214
1209
  */
1215
- function encode(s) {
1210
+ function encodeUriString(s) {
1216
1211
  return encodeURIComponent(s)
1217
1212
  .replace(/%40/g, '@')
1218
1213
  .replace(/%3A/gi, ':')
1219
1214
  .replace(/%24/g, '$')
1220
- .replace(/%2C/gi, ',')
1221
- .replace(/%3B/gi, ';');
1215
+ .replace(/%2C/gi, ',');
1216
+ }
1217
+ /**
1218
+ * This function should be used to encode both keys and values in a query string key/value. In
1219
+ * the following URL, you need to call encodeUriQuery on "k" and "v":
1220
+ *
1221
+ * http://www.site.org/html;mk=mv?k=v#f
1222
+ * @param {?} s
1223
+ * @return {?}
1224
+ */
1225
+ function encodeUriQuery(s) {
1226
+ return encodeUriString(s).replace(/%3B/gi, ';');
1227
+ }
1228
+ /**
1229
+ * This function should be used to encode a URL fragment. In the following URL, you need to call
1230
+ * encodeUriFragment on "f":
1231
+ *
1232
+ * http://www.site.org/html;mk=mv?k=v#f
1233
+ * @param {?} s
1234
+ * @return {?}
1235
+ */
1236
+ function encodeUriFragment(s) {
1237
+ return encodeURI(s);
1238
+ }
1239
+ /**
1240
+ * This function should be run on any URI segment as well as the key and value in a key/value
1241
+ * pair for matrix params. In the following URL, you need to call encodeUriSegment on "html",
1242
+ * "mk", and "mv":
1243
+ *
1244
+ * http://www.site.org/html;mk=mv?k=v#f
1245
+ * @param {?} s
1246
+ * @return {?}
1247
+ */
1248
+ function encodeUriSegment(s) {
1249
+ return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
1222
1250
  }
1223
1251
  /**
1224
1252
  * @param {?} s
@@ -1227,19 +1255,28 @@ function encode(s) {
1227
1255
  function decode(s) {
1228
1256
  return decodeURIComponent(s);
1229
1257
  }
1258
+ /**
1259
+ * @param {?} s
1260
+ * @return {?}
1261
+ */
1262
+ function decodeQuery(s) {
1263
+ return decode(s.replace(/\+/g, '%20'));
1264
+ }
1230
1265
  /**
1231
1266
  * @param {?} path
1232
1267
  * @return {?}
1233
1268
  */
1234
1269
  function serializePath(path) {
1235
- return `${encode(path.path)}${serializeParams(path.parameters)}`;
1270
+ return `${encodeUriSegment(path.path)}${serializeMatrixParams(path.parameters)}`;
1236
1271
  }
1237
1272
  /**
1238
1273
  * @param {?} params
1239
1274
  * @return {?}
1240
1275
  */
1241
- function serializeParams(params) {
1242
- return Object.keys(params).map(key => `;${encode(key)}=${encode(params[key])}`).join('');
1276
+ function serializeMatrixParams(params) {
1277
+ return Object.keys(params)
1278
+ .map(key => `;${encodeUriSegment(key)}=${encodeUriSegment(params[key])}`)
1279
+ .join('');
1243
1280
  }
1244
1281
  /**
1245
1282
  * @param {?} params
@@ -1248,8 +1285,9 @@ function serializeParams(params) {
1248
1285
  function serializeQueryParams(params) {
1249
1286
  const /** @type {?} */ strParams = Object.keys(params).map((name) => {
1250
1287
  const /** @type {?} */ value = params[name];
1251
- return Array.isArray(value) ? value.map(v => `${encode(name)}=${encode(v)}`).join('&') :
1252
- `${encode(name)}=${encode(value)}`;
1288
+ return Array.isArray(value) ?
1289
+ value.map(v => `${encodeUriQuery(name)}=${encodeUriQuery(v)}`).join('&') :
1290
+ `${encodeUriQuery(name)}=${encodeUriQuery(value)}`;
1253
1291
  });
1254
1292
  return strParams.length ? `?${strParams.join("&")}` : '';
1255
1293
  }
@@ -1315,7 +1353,7 @@ class UrlParser {
1315
1353
  * @return {?}
1316
1354
  */
1317
1355
  parseFragment() {
1318
- return this.consumeOptional('#') ? decodeURI(this.remaining) : null;
1356
+ return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
1319
1357
  }
1320
1358
  /**
1321
1359
  * @return {?}
@@ -1406,8 +1444,8 @@ class UrlParser {
1406
1444
  this.capture(value);
1407
1445
  }
1408
1446
  }
1409
- const /** @type {?} */ decodedKey = decode(key);
1410
- const /** @type {?} */ decodedVal = decode(value);
1447
+ const /** @type {?} */ decodedKey = decodeQuery(key);
1448
+ const /** @type {?} */ decodedVal = decodeQuery(value);
1411
1449
  if (params.hasOwnProperty(decodedKey)) {
1412
1450
  // Append to existing values
1413
1451
  let /** @type {?} */ currentVal = params[decodedKey];
@@ -2086,6 +2124,9 @@ function getOutlet(route) {
2086
2124
  * Use of this source code is governed by an MIT-style license that can be
2087
2125
  * found in the LICENSE file at https://angular.io/license
2088
2126
  */
2127
+ /**
2128
+ * @template T
2129
+ */
2089
2130
  class Tree {
2090
2131
  /**
2091
2132
  * @param {?} root
@@ -2175,6 +2216,9 @@ function findPath(value, node) {
2175
2216
  }
2176
2217
  return [];
2177
2218
  }
2219
+ /**
2220
+ * @template T
2221
+ */
2178
2222
  class TreeNode {
2179
2223
  /**
2180
2224
  * @param {?} value
@@ -6257,7 +6301,7 @@ function provideRouterInitializer() {
6257
6301
  /**
6258
6302
  * \@stable
6259
6303
  */
6260
- const VERSION = new Version('5.2.7');
6304
+ const VERSION = new Version('5.2.11');
6261
6305
 
6262
6306
  /**
6263
6307
  * @fileoverview added by tsickle