@ui5/task-adaptation 1.1.0 → 1.1.2

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +1 -1
  3. package/dist/annotationManager.d.ts +0 -3
  4. package/dist/annotationManager.js +8 -43
  5. package/dist/annotations/comparator/comparator.d.ts +47 -0
  6. package/dist/annotations/comparator/comparator.js +276 -0
  7. package/dist/annotations/comparator/diffCase.d.ts +4 -0
  8. package/dist/annotations/comparator/diffCase.js +3 -0
  9. package/dist/annotations/comparator/interchangableCase.d.ts +25 -0
  10. package/dist/annotations/comparator/interchangableCase.js +65 -0
  11. package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +12 -0
  12. package/dist/annotations/converter/metadataJsonReferenceUtil.js +50 -0
  13. package/dist/annotations/converter/metadataJsonUtil.d.ts +30 -0
  14. package/dist/annotations/converter/metadataJsonUtil.js +73 -0
  15. package/dist/annotations/converter/ui5JsonConverter.d.ts +21 -0
  16. package/dist/annotations/converter/ui5JsonConverter.js +253 -0
  17. package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +3 -0
  18. package/dist/annotations/converter/ui5MetadataJsonUtil.js +13 -0
  19. package/dist/annotations/converter/ui5XmlConverter.d.ts +5 -0
  20. package/dist/annotations/converter/ui5XmlConverter.js +17 -0
  21. package/dist/annotations/dataSource/dataSource.d.ts +34 -0
  22. package/dist/annotations/dataSource/dataSource.js +62 -0
  23. package/dist/annotations/dataSource/dataSourceManager.d.ts +13 -0
  24. package/dist/annotations/dataSource/dataSourceManager.js +58 -0
  25. package/dist/annotations/dataSource/dataSourceOData.d.ts +17 -0
  26. package/dist/annotations/dataSource/dataSourceOData.js +47 -0
  27. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +6 -0
  28. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +14 -0
  29. package/dist/annotations/dataSource/dataSourceODataAnnotationBeta.d.ts +6 -0
  30. package/dist/annotations/dataSource/dataSourceODataAnnotationBeta.js +18 -0
  31. package/dist/annotations/serviceRequestor.d.ts +1 -9
  32. package/dist/annotations/serviceRequestor.js +52 -17
  33. package/dist/annotations/transformers/convertV2ToV4.d.ts +4 -0
  34. package/dist/annotations/transformers/convertV2ToV4.js +16 -0
  35. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +6 -0
  36. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +44 -0
  37. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +4 -0
  38. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +17 -0
  39. package/dist/annotations/transformers/transformer.d.ts +12 -0
  40. package/dist/annotations/transformers/transformer.js +3 -0
  41. package/dist/annotations/transformers/traverseReferences.d.ts +9 -0
  42. package/dist/annotations/transformers/traverseReferences.js +67 -0
  43. package/dist/appVariantManager.d.ts +4 -2
  44. package/dist/appVariantManager.js +44 -18
  45. package/dist/baseAppManager.d.ts +2 -1
  46. package/dist/baseAppManager.js +26 -31
  47. package/dist/bundle-odata.js +5498 -0
  48. package/dist/bundle.js +1786 -13
  49. package/dist/i18nManager.d.ts +5 -7
  50. package/dist/i18nManager.js +29 -32
  51. package/dist/index.js +4 -3
  52. package/dist/model/annotationDiffStructureError.js +2 -0
  53. package/dist/model/language.js +1 -1
  54. package/dist/model/serverError.d.ts +3 -0
  55. package/dist/model/serverError.js +9 -0
  56. package/dist/model/types.d.ts +13 -2
  57. package/dist/repositories/abapRepoManager.js +2 -2
  58. package/dist/util/commonUtil.d.ts +7 -0
  59. package/dist/util/commonUtil.js +72 -18
  60. package/dist/util/i18nMerger.d.ts +1 -1
  61. package/dist/util/i18nMerger.js +3 -4
  62. package/dist/util/requestUtil.js +4 -0
  63. package/dist/util/resourceUtil.d.ts +3 -0
  64. package/dist/util/resourceUtil.js +14 -1
  65. package/dist/util/urlUtil.d.ts +4 -0
  66. package/dist/util/urlUtil.js +21 -0
  67. package/package.json +9 -6
  68. package/scripts/bundler.ts +4 -33
  69. package/scripts/metadataDownloadHelper.ts +7 -5
  70. package/scripts/rollup/bundleDefinition-odata.js +9 -0
  71. package/scripts/rollup/overrides/sap/ui/performance/Measurement.js +4 -0
  72. package/scripts/rollup/ui5Resolve.ts +34 -5
  73. package/scripts/rollup.ts +12 -3
  74. package/dist/annotations/oDataModel.d.ts +0 -20
  75. package/dist/annotations/oDataModel.js +0 -46
  76. package/dist/annotations/oDataV2Model.d.ts +0 -4
  77. package/dist/annotations/oDataV2Model.js +0 -13
  78. package/dist/util/jsonDiffUtil.d.ts +0 -28
  79. package/dist/util/jsonDiffUtil.js +0 -74
  80. package/scripts/rollup/overrides/sap/ui/thirdparty/URI.js +0 -16
package/dist/bundle.js CHANGED
@@ -1,11 +1,8 @@
1
- //1.115.0
2
1
  var window = {};
3
2
  'use strict';
4
3
 
5
4
  Object.defineProperty(exports, '__esModule', { value: true });
6
5
 
7
- var path = require('path');
8
-
9
6
  var fnIsEmptyObject = function isEmptyObject(obj) {
10
7
  for (var sName in obj) {
11
8
  return false;
@@ -57,20 +54,1796 @@ var Applier = {
57
54
  }
58
55
  };
59
56
 
60
- class URI {
61
- constructor(value) {
62
- this.value = value;
57
+ var _URI = window && window.URI;
58
+ function URI(url, base) {
59
+ var _urlSupplied = arguments.length >= 1;
60
+ var _baseSupplied = arguments.length >= 2;
61
+ if (!(this instanceof URI)) {
62
+ if (_urlSupplied) {
63
+ if (_baseSupplied) {
64
+ return new URI(url, base);
65
+ }
66
+ return new URI(url);
63
67
  }
64
-
65
- normalize() {
66
- this.value = path.posix.normalize(this.value).replace(/\\/g, "/");
67
- return this;
68
+ return new URI();
69
+ }
70
+ if (url === undefined) {
71
+ if (_urlSupplied) {
72
+ throw new TypeError("undefined is not a valid argument for URI");
68
73
  }
69
-
70
- path() {
71
- return this.value;
74
+ if (typeof location !== "undefined") {
75
+ url = location.href + "";
76
+ } else {
77
+ url = "";
78
+ }
79
+ }
80
+ if (url === null) {
81
+ if (_urlSupplied) {
82
+ throw new TypeError("null is not a valid argument for URI");
83
+ }
84
+ }
85
+ this.href(url);
86
+ if (base !== undefined) {
87
+ return this.absoluteTo(base);
88
+ }
89
+ return this;
90
+ }
91
+ function isInteger(value) {
92
+ return (/^[0-9]+$/).test(value);
93
+ }
94
+ URI.version = "1.19.11";
95
+ var p = URI.prototype;
96
+ var hasOwn$1 = Object.prototype.hasOwnProperty;
97
+ function escapeRegEx(string) {
98
+ return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
99
+ }
100
+ function getType(value) {
101
+ if (value === undefined) {
102
+ return "Undefined";
103
+ }
104
+ return String(Object.prototype.toString.call(value)).slice(8, -1);
105
+ }
106
+ function isArray(obj) {
107
+ return getType(obj) === "Array";
108
+ }
109
+ function filterArrayValues(data, value) {
110
+ var lookup = {};
111
+ var i, length;
112
+ if (getType(value) === "RegExp") {
113
+ lookup = null;
114
+ } else if (isArray(value)) {
115
+ for ((i = 0, length = value.length); i < length; i++) {
116
+ lookup[value[i]] = true;
117
+ }
118
+ } else {
119
+ lookup[value] = true;
120
+ }
121
+ for ((i = 0, length = data.length); i < length; i++) {
122
+ var _match = lookup && lookup[data[i]] !== undefined || !lookup && value.test(data[i]);
123
+ if (_match) {
124
+ data.splice(i, 1);
125
+ length--;
126
+ i--;
127
+ }
128
+ }
129
+ return data;
130
+ }
131
+ function arrayContains(list, value) {
132
+ var i, length;
133
+ if (isArray(value)) {
134
+ for ((i = 0, length = value.length); i < length; i++) {
135
+ if (!arrayContains(list, value[i])) {
136
+ return false;
137
+ }
138
+ }
139
+ return true;
140
+ }
141
+ var _type = getType(value);
142
+ for ((i = 0, length = list.length); i < length; i++) {
143
+ if (_type === "RegExp") {
144
+ if (typeof list[i] === "string" && list[i].match(value)) {
145
+ return true;
146
+ }
147
+ } else if (list[i] === value) {
148
+ return true;
149
+ }
150
+ }
151
+ return false;
152
+ }
153
+ function arraysEqual(one, two) {
154
+ if (!isArray(one) || !isArray(two)) {
155
+ return false;
156
+ }
157
+ if (one.length !== two.length) {
158
+ return false;
159
+ }
160
+ one.sort();
161
+ two.sort();
162
+ for (var i = 0, l = one.length; i < l; i++) {
163
+ if (one[i] !== two[i]) {
164
+ return false;
165
+ }
166
+ }
167
+ return true;
168
+ }
169
+ function trimSlashes(text) {
170
+ var trim_expression = /^\/+|\/+$/g;
171
+ return text.replace(trim_expression, "");
172
+ }
173
+ URI._parts = function () {
174
+ return {
175
+ protocol: null,
176
+ username: null,
177
+ password: null,
178
+ hostname: null,
179
+ urn: null,
180
+ port: null,
181
+ path: null,
182
+ query: null,
183
+ fragment: null,
184
+ preventInvalidHostname: URI.preventInvalidHostname,
185
+ duplicateQueryParameters: URI.duplicateQueryParameters,
186
+ escapeQuerySpace: URI.escapeQuerySpace
187
+ };
188
+ };
189
+ URI.preventInvalidHostname = false;
190
+ URI.duplicateQueryParameters = false;
191
+ URI.escapeQuerySpace = true;
192
+ URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
193
+ URI.idn_expression = /[^a-z0-9\._-]/i;
194
+ URI.punycode_expression = /(xn--)/i;
195
+ URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
196
+ URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
197
+ URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
198
+ URI.findUri = {
199
+ start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
200
+ end: /[\s\r\n]|$/,
201
+ trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
202
+ parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g
203
+ };
204
+ URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
205
+ URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g;
206
+ URI.defaultPorts = {
207
+ http: "80",
208
+ https: "443",
209
+ ftp: "21",
210
+ gopher: "70",
211
+ ws: "80",
212
+ wss: "443"
213
+ };
214
+ URI.hostProtocols = ["http", "https"];
215
+ URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/;
216
+ URI.domAttributes = {
217
+ "a": "href",
218
+ "blockquote": "cite",
219
+ "link": "href",
220
+ "base": "href",
221
+ "script": "src",
222
+ "form": "action",
223
+ "img": "src",
224
+ "area": "href",
225
+ "iframe": "src",
226
+ "embed": "src",
227
+ "source": "src",
228
+ "track": "src",
229
+ "input": "src",
230
+ "audio": "src",
231
+ "video": "src"
232
+ };
233
+ URI.getDomAttribute = function (node) {
234
+ if (!node || !node.nodeName) {
235
+ return undefined;
236
+ }
237
+ var nodeName = node.nodeName.toLowerCase();
238
+ if (nodeName === "input" && node.type !== "image") {
239
+ return undefined;
240
+ }
241
+ return URI.domAttributes[nodeName];
242
+ };
243
+ function escapeForDumbFirefox36(value) {
244
+ return escape(value);
245
+ }
246
+ function strictEncodeURIComponent(string) {
247
+ return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, "%2A");
248
+ }
249
+ URI.encode = strictEncodeURIComponent;
250
+ URI.decode = decodeURIComponent;
251
+ URI.iso8859 = function () {
252
+ URI.encode = escape;
253
+ URI.decode = unescape;
254
+ };
255
+ URI.unicode = function () {
256
+ URI.encode = strictEncodeURIComponent;
257
+ URI.decode = decodeURIComponent;
258
+ };
259
+ URI.characters = {
260
+ pathname: {
261
+ encode: {
262
+ expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
263
+ map: {
264
+ "%24": "$",
265
+ "%26": "&",
266
+ "%2B": "+",
267
+ "%2C": ",",
268
+ "%3B": ";",
269
+ "%3D": "=",
270
+ "%3A": ":",
271
+ "%40": "@"
272
+ }
273
+ },
274
+ decode: {
275
+ expression: /[\/\?#]/g,
276
+ map: {
277
+ "/": "%2F",
278
+ "?": "%3F",
279
+ "#": "%23"
280
+ }
281
+ }
282
+ },
283
+ reserved: {
284
+ encode: {
285
+ expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
286
+ map: {
287
+ "%3A": ":",
288
+ "%2F": "/",
289
+ "%3F": "?",
290
+ "%23": "#",
291
+ "%5B": "[",
292
+ "%5D": "]",
293
+ "%40": "@",
294
+ "%21": "!",
295
+ "%24": "$",
296
+ "%26": "&",
297
+ "%27": "'",
298
+ "%28": "(",
299
+ "%29": ")",
300
+ "%2A": "*",
301
+ "%2B": "+",
302
+ "%2C": ",",
303
+ "%3B": ";",
304
+ "%3D": "="
305
+ }
306
+ }
307
+ },
308
+ urnpath: {
309
+ encode: {
310
+ expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
311
+ map: {
312
+ "%21": "!",
313
+ "%24": "$",
314
+ "%27": "'",
315
+ "%28": "(",
316
+ "%29": ")",
317
+ "%2A": "*",
318
+ "%2B": "+",
319
+ "%2C": ",",
320
+ "%3B": ";",
321
+ "%3D": "=",
322
+ "%40": "@"
323
+ }
324
+ },
325
+ decode: {
326
+ expression: /[\/\?#:]/g,
327
+ map: {
328
+ "/": "%2F",
329
+ "?": "%3F",
330
+ "#": "%23",
331
+ ":": "%3A"
332
+ }
333
+ }
334
+ }
335
+ };
336
+ URI.encodeQuery = function (string, escapeQuerySpace) {
337
+ var escaped = URI.encode(string + "");
338
+ if (escapeQuerySpace === undefined) {
339
+ escapeQuerySpace = URI.escapeQuerySpace;
340
+ }
341
+ return escapeQuerySpace ? escaped.replace(/%20/g, "+") : escaped;
342
+ };
343
+ URI.decodeQuery = function (string, escapeQuerySpace) {
344
+ string += "";
345
+ if (escapeQuerySpace === undefined) {
346
+ escapeQuerySpace = URI.escapeQuerySpace;
347
+ }
348
+ try {
349
+ return URI.decode(escapeQuerySpace ? string.replace(/\+/g, "%20") : string);
350
+ } catch (e) {
351
+ return string;
352
+ }
353
+ };
354
+ var _parts = {
355
+ "encode": "encode",
356
+ "decode": "decode"
357
+ };
358
+ var _part;
359
+ var generateAccessor = function (_group, _part) {
360
+ return function (string) {
361
+ try {
362
+ return URI[_part](string + "").replace(URI.characters[_group][_part].expression, function (c) {
363
+ return URI.characters[_group][_part].map[c];
364
+ });
365
+ } catch (e) {
366
+ return string;
367
+ }
368
+ };
369
+ };
370
+ for (_part in _parts) {
371
+ URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]);
372
+ URI[_part + "UrnPathSegment"] = generateAccessor("urnpath", _parts[_part]);
373
+ }
374
+ var generateSegmentedPathFunction = function (_sep, _codingFuncName, _innerCodingFuncName) {
375
+ return function (string) {
376
+ var actualCodingFunc;
377
+ if (!_innerCodingFuncName) {
378
+ actualCodingFunc = URI[_codingFuncName];
379
+ } else {
380
+ actualCodingFunc = function (string) {
381
+ return URI[_codingFuncName](URI[_innerCodingFuncName](string));
382
+ };
383
+ }
384
+ var segments = (string + "").split(_sep);
385
+ for (var i = 0, length = segments.length; i < length; i++) {
386
+ segments[i] = actualCodingFunc(segments[i]);
387
+ }
388
+ return segments.join(_sep);
389
+ };
390
+ };
391
+ URI.decodePath = generateSegmentedPathFunction("/", "decodePathSegment");
392
+ URI.decodeUrnPath = generateSegmentedPathFunction(":", "decodeUrnPathSegment");
393
+ URI.recodePath = generateSegmentedPathFunction("/", "encodePathSegment", "decode");
394
+ URI.recodeUrnPath = generateSegmentedPathFunction(":", "encodeUrnPathSegment", "decode");
395
+ URI.encodeReserved = generateAccessor("reserved", "encode");
396
+ URI.parse = function (string, parts) {
397
+ var pos;
398
+ if (!parts) {
399
+ parts = {
400
+ preventInvalidHostname: URI.preventInvalidHostname
401
+ };
402
+ }
403
+ string = string.replace(URI.leading_whitespace_expression, "");
404
+ string = string.replace(URI.ascii_tab_whitespace, "");
405
+ pos = string.indexOf("#");
406
+ if (pos > -1) {
407
+ parts.fragment = string.substring(pos + 1) || null;
408
+ string = string.substring(0, pos);
409
+ }
410
+ pos = string.indexOf("?");
411
+ if (pos > -1) {
412
+ parts.query = string.substring(pos + 1) || null;
413
+ string = string.substring(0, pos);
414
+ }
415
+ string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, "$1://");
416
+ string = string.replace(/^[/\\]{2,}/i, "//");
417
+ if (string.substring(0, 2) === "//") {
418
+ parts.protocol = null;
419
+ string = string.substring(2);
420
+ string = URI.parseAuthority(string, parts);
421
+ } else {
422
+ pos = string.indexOf(":");
423
+ if (pos > -1) {
424
+ parts.protocol = string.substring(0, pos) || null;
425
+ if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
426
+ parts.protocol = undefined;
427
+ } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, "/") === "//") {
428
+ string = string.substring(pos + 3);
429
+ string = URI.parseAuthority(string, parts);
430
+ } else {
431
+ string = string.substring(pos + 1);
432
+ parts.urn = true;
433
+ }
434
+ }
435
+ }
436
+ parts.path = string;
437
+ return parts;
438
+ };
439
+ URI.parseHost = function (string, parts) {
440
+ if (!string) {
441
+ string = "";
442
+ }
443
+ string = string.replace(/\\/g, "/");
444
+ var pos = string.indexOf("/");
445
+ var bracketPos;
446
+ var t;
447
+ if (pos === -1) {
448
+ pos = string.length;
449
+ }
450
+ if (string.charAt(0) === "[") {
451
+ bracketPos = string.indexOf("]");
452
+ parts.hostname = string.substring(1, bracketPos) || null;
453
+ parts.port = string.substring(bracketPos + 2, pos) || null;
454
+ if (parts.port === "/") {
455
+ parts.port = null;
456
+ }
457
+ } else {
458
+ var firstColon = string.indexOf(":");
459
+ var firstSlash = string.indexOf("/");
460
+ var nextColon = string.indexOf(":", firstColon + 1);
461
+ if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
462
+ parts.hostname = string.substring(0, pos) || null;
463
+ parts.port = null;
464
+ } else {
465
+ t = string.substring(0, pos).split(":");
466
+ parts.hostname = t[0] || null;
467
+ parts.port = t[1] || null;
468
+ }
469
+ }
470
+ if (parts.hostname && string.substring(pos).charAt(0) !== "/") {
471
+ pos++;
472
+ string = "/" + string;
473
+ }
474
+ if (parts.preventInvalidHostname) {
475
+ URI.ensureValidHostname(parts.hostname, parts.protocol);
476
+ }
477
+ if (parts.port) {
478
+ URI.ensureValidPort(parts.port);
479
+ }
480
+ return string.substring(pos) || "/";
481
+ };
482
+ URI.parseAuthority = function (string, parts) {
483
+ string = URI.parseUserinfo(string, parts);
484
+ return URI.parseHost(string, parts);
485
+ };
486
+ URI.parseUserinfo = function (string, parts) {
487
+ var _string = string;
488
+ var firstBackSlash = string.indexOf("\\");
489
+ if (firstBackSlash !== -1) {
490
+ string = string.replace(/\\/g, "/");
491
+ }
492
+ var firstSlash = string.indexOf("/");
493
+ var pos = string.lastIndexOf("@", firstSlash > -1 ? firstSlash : string.length - 1);
494
+ var t;
495
+ if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
496
+ t = string.substring(0, pos).split(":");
497
+ parts.username = t[0] ? URI.decode(t[0]) : null;
498
+ t.shift();
499
+ parts.password = t[0] ? URI.decode(t.join(":")) : null;
500
+ string = _string.substring(pos + 1);
501
+ } else {
502
+ parts.username = null;
503
+ parts.password = null;
504
+ }
505
+ return string;
506
+ };
507
+ URI.parseQuery = function (string, escapeQuerySpace) {
508
+ if (!string) {
509
+ return {};
510
+ }
511
+ string = string.replace(/&+/g, "&").replace(/^\?*&*|&+$/g, "");
512
+ if (!string) {
513
+ return {};
514
+ }
515
+ var items = {};
516
+ var splits = string.split("&");
517
+ var length = splits.length;
518
+ var v, name, value;
519
+ for (var i = 0; i < length; i++) {
520
+ v = splits[i].split("=");
521
+ name = URI.decodeQuery(v.shift(), escapeQuerySpace);
522
+ value = v.length ? URI.decodeQuery(v.join("="), escapeQuerySpace) : null;
523
+ if (name === "__proto__") {
524
+ continue;
525
+ } else if (hasOwn$1.call(items, name)) {
526
+ if (typeof items[name] === "string" || items[name] === null) {
527
+ items[name] = [items[name]];
528
+ }
529
+ items[name].push(value);
530
+ } else {
531
+ items[name] = value;
532
+ }
533
+ }
534
+ return items;
535
+ };
536
+ URI.build = function (parts) {
537
+ var t = "";
538
+ var requireAbsolutePath = false;
539
+ if (parts.protocol) {
540
+ t += parts.protocol + ":";
541
+ }
542
+ if (!parts.urn && (t || parts.hostname)) {
543
+ t += "//";
544
+ requireAbsolutePath = true;
545
+ }
546
+ t += URI.buildAuthority(parts) || "";
547
+ if (typeof parts.path === "string") {
548
+ if (parts.path.charAt(0) !== "/" && requireAbsolutePath) {
549
+ t += "/";
550
+ }
551
+ t += parts.path;
552
+ }
553
+ if (typeof parts.query === "string" && parts.query) {
554
+ t += "?" + parts.query;
555
+ }
556
+ if (typeof parts.fragment === "string" && parts.fragment) {
557
+ t += "#" + parts.fragment;
558
+ }
559
+ return t;
560
+ };
561
+ URI.buildHost = function (parts) {
562
+ var t = "";
563
+ if (!parts.hostname) {
564
+ return "";
565
+ } else if (URI.ip6_expression.test(parts.hostname)) {
566
+ t += "[" + parts.hostname + "]";
567
+ } else {
568
+ t += parts.hostname;
569
+ }
570
+ if (parts.port) {
571
+ t += ":" + parts.port;
572
+ }
573
+ return t;
574
+ };
575
+ URI.buildAuthority = function (parts) {
576
+ return URI.buildUserinfo(parts) + URI.buildHost(parts);
577
+ };
578
+ URI.buildUserinfo = function (parts) {
579
+ var t = "";
580
+ if (parts.username) {
581
+ t += URI.encode(parts.username);
582
+ }
583
+ if (parts.password) {
584
+ t += ":" + URI.encode(parts.password);
585
+ }
586
+ if (t) {
587
+ t += "@";
588
+ }
589
+ return t;
590
+ };
591
+ URI.buildQuery = function (data, duplicateQueryParameters, escapeQuerySpace) {
592
+ var t = "";
593
+ var unique, key, i, length;
594
+ for (key in data) {
595
+ if (key === "__proto__") {
596
+ continue;
597
+ } else if (hasOwn$1.call(data, key)) {
598
+ if (isArray(data[key])) {
599
+ unique = {};
600
+ for ((i = 0, length = data[key].length); i < length; i++) {
601
+ if (data[key][i] !== undefined && unique[data[key][i] + ""] === undefined) {
602
+ t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
603
+ if (duplicateQueryParameters !== true) {
604
+ unique[data[key][i] + ""] = true;
605
+ }
606
+ }
607
+ }
608
+ } else if (data[key] !== undefined) {
609
+ t += "&" + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
610
+ }
611
+ }
612
+ }
613
+ return t.substring(1);
614
+ };
615
+ URI.buildQueryParameter = function (name, value, escapeQuerySpace) {
616
+ return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : "");
617
+ };
618
+ URI.addQuery = function (data, name, value) {
619
+ if (typeof name === "object") {
620
+ for (var key in name) {
621
+ if (hasOwn$1.call(name, key)) {
622
+ URI.addQuery(data, key, name[key]);
623
+ }
624
+ }
625
+ } else if (typeof name === "string") {
626
+ if (data[name] === undefined) {
627
+ data[name] = value;
628
+ return;
629
+ } else if (typeof data[name] === "string") {
630
+ data[name] = [data[name]];
631
+ }
632
+ if (!isArray(value)) {
633
+ value = [value];
634
+ }
635
+ data[name] = (data[name] || []).concat(value);
636
+ } else {
637
+ throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
638
+ }
639
+ };
640
+ URI.setQuery = function (data, name, value) {
641
+ if (typeof name === "object") {
642
+ for (var key in name) {
643
+ if (hasOwn$1.call(name, key)) {
644
+ URI.setQuery(data, key, name[key]);
645
+ }
646
+ }
647
+ } else if (typeof name === "string") {
648
+ data[name] = value === undefined ? null : value;
649
+ } else {
650
+ throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");
651
+ }
652
+ };
653
+ URI.removeQuery = function (data, name, value) {
654
+ var i, length, key;
655
+ if (isArray(name)) {
656
+ for ((i = 0, length = name.length); i < length; i++) {
657
+ data[name[i]] = undefined;
658
+ }
659
+ } else if (getType(name) === "RegExp") {
660
+ for (key in data) {
661
+ if (name.test(key)) {
662
+ data[key] = undefined;
663
+ }
664
+ }
665
+ } else if (typeof name === "object") {
666
+ for (key in name) {
667
+ if (hasOwn$1.call(name, key)) {
668
+ URI.removeQuery(data, key, name[key]);
669
+ }
670
+ }
671
+ } else if (typeof name === "string") {
672
+ if (value !== undefined) {
673
+ if (getType(value) === "RegExp") {
674
+ if (!isArray(data[name]) && value.test(data[name])) {
675
+ data[name] = undefined;
676
+ } else {
677
+ data[name] = filterArrayValues(data[name], value);
678
+ }
679
+ } else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
680
+ data[name] = undefined;
681
+ } else if (isArray(data[name])) {
682
+ data[name] = filterArrayValues(data[name], value);
683
+ }
684
+ } else {
685
+ data[name] = undefined;
686
+ }
687
+ } else {
688
+ throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");
689
+ }
690
+ };
691
+ URI.hasQuery = function (data, name, value, withinArray) {
692
+ switch (getType(name)) {
693
+ case "String":
694
+ break;
695
+ case "RegExp":
696
+ for (var key in data) {
697
+ if (hasOwn$1.call(data, key)) {
698
+ if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {
699
+ return true;
700
+ }
701
+ }
702
+ }
703
+ return false;
704
+ case "Object":
705
+ for (var _key in name) {
706
+ if (hasOwn$1.call(name, _key)) {
707
+ if (!URI.hasQuery(data, _key, name[_key])) {
708
+ return false;
709
+ }
710
+ }
711
+ }
712
+ return true;
713
+ default:
714
+ throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");
715
+ }
716
+ switch (getType(value)) {
717
+ case "Undefined":
718
+ return (name in data);
719
+ case "Boolean":
720
+ var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
721
+ return value === _booly;
722
+ case "Function":
723
+ return !!value(data[name], name, data);
724
+ case "Array":
725
+ if (!isArray(data[name])) {
726
+ return false;
727
+ }
728
+ var op = withinArray ? arrayContains : arraysEqual;
729
+ return op(data[name], value);
730
+ case "RegExp":
731
+ if (!isArray(data[name])) {
732
+ return Boolean(data[name] && data[name].match(value));
733
+ }
734
+ if (!withinArray) {
735
+ return false;
736
+ }
737
+ return arrayContains(data[name], value);
738
+ case "Number":
739
+ value = String(value);
740
+ case "String":
741
+ if (!isArray(data[name])) {
742
+ return data[name] === value;
743
+ }
744
+ if (!withinArray) {
745
+ return false;
746
+ }
747
+ return arrayContains(data[name], value);
748
+ default:
749
+ throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
750
+ }
751
+ };
752
+ URI.joinPaths = function () {
753
+ var input = [];
754
+ var segments = [];
755
+ var nonEmptySegments = 0;
756
+ for (var i = 0; i < arguments.length; i++) {
757
+ var url = new URI(arguments[i]);
758
+ input.push(url);
759
+ var _segments = url.segment();
760
+ for (var s = 0; s < _segments.length; s++) {
761
+ if (typeof _segments[s] === "string") {
762
+ segments.push(_segments[s]);
763
+ }
764
+ if (_segments[s]) {
765
+ nonEmptySegments++;
766
+ }
767
+ }
768
+ }
769
+ if (!segments.length || !nonEmptySegments) {
770
+ return new URI("");
771
+ }
772
+ var uri = new URI("").segment(segments);
773
+ if (input[0].path() === "" || input[0].path().slice(0, 1) === "/") {
774
+ uri.path("/" + uri.path());
775
+ }
776
+ return uri.normalize();
777
+ };
778
+ URI.commonPath = function (one, two) {
779
+ var length = Math.min(one.length, two.length);
780
+ var pos;
781
+ for (pos = 0; pos < length; pos++) {
782
+ if (one.charAt(pos) !== two.charAt(pos)) {
783
+ pos--;
784
+ break;
785
+ }
786
+ }
787
+ if (pos < 1) {
788
+ return one.charAt(0) === two.charAt(0) && one.charAt(0) === "/" ? "/" : "";
789
+ }
790
+ if (one.charAt(pos) !== "/" || two.charAt(pos) !== "/") {
791
+ pos = one.substring(0, pos).lastIndexOf("/");
792
+ }
793
+ return one.substring(0, pos + 1);
794
+ };
795
+ URI.withinString = function (string, callback, options) {
796
+ options || (options = {});
797
+ var _start = options.start || URI.findUri.start;
798
+ var _end = options.end || URI.findUri.end;
799
+ var _trim = options.trim || URI.findUri.trim;
800
+ var _parens = options.parens || URI.findUri.parens;
801
+ var _attributeOpen = /[a-z0-9-]=["']?$/i;
802
+ _start.lastIndex = 0;
803
+ while (true) {
804
+ var match = _start.exec(string);
805
+ if (!match) {
806
+ break;
807
+ }
808
+ var start = match.index;
809
+ if (options.ignoreHtml) {
810
+ var attributeOpen = string.slice(Math.max(start - 3, 0), start);
811
+ if (attributeOpen && _attributeOpen.test(attributeOpen)) {
812
+ continue;
813
+ }
814
+ }
815
+ var end = start + string.slice(start).search(_end);
816
+ var slice = string.slice(start, end);
817
+ var parensEnd = -1;
818
+ while (true) {
819
+ var parensMatch = _parens.exec(slice);
820
+ if (!parensMatch) {
821
+ break;
822
+ }
823
+ var parensMatchEnd = parensMatch.index + parensMatch[0].length;
824
+ parensEnd = Math.max(parensEnd, parensMatchEnd);
825
+ }
826
+ if (parensEnd > -1) {
827
+ slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, "");
828
+ } else {
829
+ slice = slice.replace(_trim, "");
830
+ }
831
+ if (slice.length <= match[0].length) {
832
+ continue;
833
+ }
834
+ if (options.ignore && options.ignore.test(slice)) {
835
+ continue;
836
+ }
837
+ end = start + slice.length;
838
+ var result = callback(slice, start, end, string);
839
+ if (result === undefined) {
840
+ _start.lastIndex = end;
841
+ continue;
842
+ }
843
+ result = String(result);
844
+ string = string.slice(0, start) + result + string.slice(end);
845
+ _start.lastIndex = start + result.length;
846
+ }
847
+ _start.lastIndex = 0;
848
+ return string;
849
+ };
850
+ URI.ensureValidHostname = function (v, protocol) {
851
+ var hasHostname = !!v;
852
+ var hasProtocol = !!protocol;
853
+ var rejectEmptyHostname = false;
854
+ if (hasProtocol) {
855
+ rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
856
+ }
857
+ if (rejectEmptyHostname && !hasHostname) {
858
+ throw new TypeError("Hostname cannot be empty, if protocol is " + protocol);
859
+ } else if (v && v.match(URI.invalid_hostname_characters)) {
860
+ if (!punycode) {
861
+ throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available");
862
+ }
863
+ if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
864
+ throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-:_]");
865
+ }
866
+ }
867
+ };
868
+ URI.ensureValidPort = function (v) {
869
+ if (!v) {
870
+ return;
871
+ }
872
+ var port = Number(v);
873
+ if (isInteger(port) && port > 0 && port < 65536) {
874
+ return;
875
+ }
876
+ throw new TypeError("Port \"" + v + "\" is not a valid port");
877
+ };
878
+ URI.noConflict = function (removeAll) {
879
+ if (removeAll) {
880
+ var unconflicted = {
881
+ URI: this.noConflict()
882
+ };
883
+ if (window.URITemplate && typeof window.URITemplate.noConflict === "function") {
884
+ unconflicted.URITemplate = window.URITemplate.noConflict();
885
+ }
886
+ if (window.IPv6 && typeof window.IPv6.noConflict === "function") {
887
+ unconflicted.IPv6 = window.IPv6.noConflict();
888
+ }
889
+ if (window.SecondLevelDomains && typeof window.SecondLevelDomains.noConflict === "function") {
890
+ unconflicted.SecondLevelDomains = window.SecondLevelDomains.noConflict();
72
891
  }
892
+ return unconflicted;
893
+ } else if (window.URI === this) {
894
+ window.URI = _URI;
895
+ }
896
+ return this;
897
+ };
898
+ p.build = function (deferBuild) {
899
+ if (deferBuild === true) {
900
+ this._deferred_build = true;
901
+ } else if (deferBuild === undefined || this._deferred_build) {
902
+ this._string = URI.build(this._parts);
903
+ this._deferred_build = false;
904
+ }
905
+ return this;
906
+ };
907
+ p.clone = function () {
908
+ return new URI(this);
909
+ };
910
+ p.valueOf = p.toString = function () {
911
+ return this.build(false)._string;
912
+ };
913
+ function generateSimpleAccessor(_part) {
914
+ return function (v, build) {
915
+ if (v === undefined) {
916
+ return this._parts[_part] || "";
917
+ } else {
918
+ this._parts[_part] = v || null;
919
+ this.build(!build);
920
+ return this;
921
+ }
922
+ };
73
923
  }
924
+ function generatePrefixAccessor(_part, _key) {
925
+ return function (v, build) {
926
+ if (v === undefined) {
927
+ return this._parts[_part] || "";
928
+ } else {
929
+ if (v !== null) {
930
+ v = v + "";
931
+ if (v.charAt(0) === _key) {
932
+ v = v.substring(1);
933
+ }
934
+ }
935
+ this._parts[_part] = v;
936
+ this.build(!build);
937
+ return this;
938
+ }
939
+ };
940
+ }
941
+ p.protocol = generateSimpleAccessor("protocol");
942
+ p.username = generateSimpleAccessor("username");
943
+ p.password = generateSimpleAccessor("password");
944
+ p.hostname = generateSimpleAccessor("hostname");
945
+ p.port = generateSimpleAccessor("port");
946
+ p.query = generatePrefixAccessor("query", "?");
947
+ p.fragment = generatePrefixAccessor("fragment", "#");
948
+ p.search = function (v, build) {
949
+ var t = this.query(v, build);
950
+ return typeof t === "string" && t.length ? "?" + t : t;
951
+ };
952
+ p.hash = function (v, build) {
953
+ var t = this.fragment(v, build);
954
+ return typeof t === "string" && t.length ? "#" + t : t;
955
+ };
956
+ p.pathname = function (v, build) {
957
+ if (v === undefined || v === true) {
958
+ var res = this._parts.path || (this._parts.hostname ? "/" : "");
959
+ return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
960
+ } else {
961
+ if (this._parts.urn) {
962
+ this._parts.path = v ? URI.recodeUrnPath(v) : "";
963
+ } else {
964
+ this._parts.path = v ? URI.recodePath(v) : "/";
965
+ }
966
+ this.build(!build);
967
+ return this;
968
+ }
969
+ };
970
+ p.path = p.pathname;
971
+ p.href = function (href, build) {
972
+ var key;
973
+ if (href === undefined) {
974
+ return this.toString();
975
+ }
976
+ this._string = "";
977
+ this._parts = URI._parts();
978
+ var _URI = href instanceof URI;
979
+ var _object = typeof href === "object" && (href.hostname || href.path || href.pathname);
980
+ if (href.nodeName) {
981
+ var attribute = URI.getDomAttribute(href);
982
+ href = href[attribute] || "";
983
+ _object = false;
984
+ }
985
+ if (!_URI && _object && href.pathname !== undefined) {
986
+ href = href.toString();
987
+ }
988
+ if (typeof href === "string" || href instanceof String) {
989
+ this._parts = URI.parse(String(href), this._parts);
990
+ } else if (_URI || _object) {
991
+ var src = _URI ? href._parts : href;
992
+ for (key in src) {
993
+ if (key === "query") {
994
+ continue;
995
+ }
996
+ if (hasOwn$1.call(this._parts, key)) {
997
+ this._parts[key] = src[key];
998
+ }
999
+ }
1000
+ if (src.query) {
1001
+ this.query(src.query, false);
1002
+ }
1003
+ } else {
1004
+ throw new TypeError("invalid input");
1005
+ }
1006
+ this.build(!build);
1007
+ return this;
1008
+ };
1009
+ p.is = function (what) {
1010
+ var ip = false;
1011
+ var ip4 = false;
1012
+ var ip6 = false;
1013
+ var name = false;
1014
+ var sld = false;
1015
+ var idn = false;
1016
+ var punycode = false;
1017
+ var relative = !this._parts.urn;
1018
+ if (this._parts.hostname) {
1019
+ relative = false;
1020
+ ip4 = URI.ip4_expression.test(this._parts.hostname);
1021
+ ip6 = URI.ip6_expression.test(this._parts.hostname);
1022
+ ip = ip4 || ip6;
1023
+ name = !ip;
1024
+ sld = name && SLD && SLD.has(this._parts.hostname);
1025
+ idn = name && URI.idn_expression.test(this._parts.hostname);
1026
+ punycode = name && URI.punycode_expression.test(this._parts.hostname);
1027
+ }
1028
+ switch (what.toLowerCase()) {
1029
+ case "relative":
1030
+ return relative;
1031
+ case "absolute":
1032
+ return !relative;
1033
+ case "domain":
1034
+ case "name":
1035
+ return name;
1036
+ case "sld":
1037
+ return sld;
1038
+ case "ip":
1039
+ return ip;
1040
+ case "ip4":
1041
+ case "ipv4":
1042
+ case "inet4":
1043
+ return ip4;
1044
+ case "ip6":
1045
+ case "ipv6":
1046
+ case "inet6":
1047
+ return ip6;
1048
+ case "idn":
1049
+ return idn;
1050
+ case "url":
1051
+ return !this._parts.urn;
1052
+ case "urn":
1053
+ return !!this._parts.urn;
1054
+ case "punycode":
1055
+ return punycode;
1056
+ }
1057
+ return null;
1058
+ };
1059
+ var _protocol = p.protocol;
1060
+ var _port = p.port;
1061
+ var _hostname = p.hostname;
1062
+ p.protocol = function (v, build) {
1063
+ if (v) {
1064
+ v = v.replace(/:(\/\/)?$/, "");
1065
+ if (!v.match(URI.protocol_expression)) {
1066
+ throw new TypeError("Protocol \"" + v + "\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");
1067
+ }
1068
+ }
1069
+ return _protocol.call(this, v, build);
1070
+ };
1071
+ p.scheme = p.protocol;
1072
+ p.port = function (v, build) {
1073
+ if (this._parts.urn) {
1074
+ return v === undefined ? "" : this;
1075
+ }
1076
+ if (v !== undefined) {
1077
+ if (v === 0) {
1078
+ v = null;
1079
+ }
1080
+ if (v) {
1081
+ v += "";
1082
+ if (v.charAt(0) === ":") {
1083
+ v = v.substring(1);
1084
+ }
1085
+ URI.ensureValidPort(v);
1086
+ }
1087
+ }
1088
+ return _port.call(this, v, build);
1089
+ };
1090
+ p.hostname = function (v, build) {
1091
+ if (this._parts.urn) {
1092
+ return v === undefined ? "" : this;
1093
+ }
1094
+ if (v !== undefined) {
1095
+ var x = {
1096
+ preventInvalidHostname: this._parts.preventInvalidHostname
1097
+ };
1098
+ var res = URI.parseHost(v, x);
1099
+ if (res !== "/") {
1100
+ throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
1101
+ }
1102
+ v = x.hostname;
1103
+ if (this._parts.preventInvalidHostname) {
1104
+ URI.ensureValidHostname(v, this._parts.protocol);
1105
+ }
1106
+ }
1107
+ return _hostname.call(this, v, build);
1108
+ };
1109
+ p.origin = function (v, build) {
1110
+ if (this._parts.urn) {
1111
+ return v === undefined ? "" : this;
1112
+ }
1113
+ if (v === undefined) {
1114
+ var protocol = this.protocol();
1115
+ var authority = this.authority();
1116
+ if (!authority) {
1117
+ return "";
1118
+ }
1119
+ return (protocol ? protocol + "://" : "") + this.authority();
1120
+ } else {
1121
+ var origin = URI(v);
1122
+ this.protocol(origin.protocol()).authority(origin.authority()).build(!build);
1123
+ return this;
1124
+ }
1125
+ };
1126
+ p.host = function (v, build) {
1127
+ if (this._parts.urn) {
1128
+ return v === undefined ? "" : this;
1129
+ }
1130
+ if (v === undefined) {
1131
+ return this._parts.hostname ? URI.buildHost(this._parts) : "";
1132
+ } else {
1133
+ var res = URI.parseHost(v, this._parts);
1134
+ if (res !== "/") {
1135
+ throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
1136
+ }
1137
+ this.build(!build);
1138
+ return this;
1139
+ }
1140
+ };
1141
+ p.authority = function (v, build) {
1142
+ if (this._parts.urn) {
1143
+ return v === undefined ? "" : this;
1144
+ }
1145
+ if (v === undefined) {
1146
+ return this._parts.hostname ? URI.buildAuthority(this._parts) : "";
1147
+ } else {
1148
+ var res = URI.parseAuthority(v, this._parts);
1149
+ if (res !== "/") {
1150
+ throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
1151
+ }
1152
+ this.build(!build);
1153
+ return this;
1154
+ }
1155
+ };
1156
+ p.userinfo = function (v, build) {
1157
+ if (this._parts.urn) {
1158
+ return v === undefined ? "" : this;
1159
+ }
1160
+ if (v === undefined) {
1161
+ var t = URI.buildUserinfo(this._parts);
1162
+ return t ? t.substring(0, t.length - 1) : t;
1163
+ } else {
1164
+ if (v[v.length - 1] !== "@") {
1165
+ v += "@";
1166
+ }
1167
+ URI.parseUserinfo(v, this._parts);
1168
+ this.build(!build);
1169
+ return this;
1170
+ }
1171
+ };
1172
+ p.resource = function (v, build) {
1173
+ var parts;
1174
+ if (v === undefined) {
1175
+ return this.path() + this.search() + this.hash();
1176
+ }
1177
+ parts = URI.parse(v);
1178
+ this._parts.path = parts.path;
1179
+ this._parts.query = parts.query;
1180
+ this._parts.fragment = parts.fragment;
1181
+ this.build(!build);
1182
+ return this;
1183
+ };
1184
+ p.subdomain = function (v, build) {
1185
+ if (this._parts.urn) {
1186
+ return v === undefined ? "" : this;
1187
+ }
1188
+ if (v === undefined) {
1189
+ if (!this._parts.hostname || this.is("IP")) {
1190
+ return "";
1191
+ }
1192
+ var end = this._parts.hostname.length - this.domain().length - 1;
1193
+ return this._parts.hostname.substring(0, end) || "";
1194
+ } else {
1195
+ var e = this._parts.hostname.length - this.domain().length;
1196
+ var sub = this._parts.hostname.substring(0, e);
1197
+ var replace = new RegExp("^" + escapeRegEx(sub));
1198
+ if (v && v.charAt(v.length - 1) !== ".") {
1199
+ v += ".";
1200
+ }
1201
+ if (v.indexOf(":") !== -1) {
1202
+ throw new TypeError("Domains cannot contain colons");
1203
+ }
1204
+ if (v) {
1205
+ URI.ensureValidHostname(v, this._parts.protocol);
1206
+ }
1207
+ this._parts.hostname = this._parts.hostname.replace(replace, v);
1208
+ this.build(!build);
1209
+ return this;
1210
+ }
1211
+ };
1212
+ p.domain = function (v, build) {
1213
+ if (this._parts.urn) {
1214
+ return v === undefined ? "" : this;
1215
+ }
1216
+ if (typeof v === "boolean") {
1217
+ build = v;
1218
+ v = undefined;
1219
+ }
1220
+ if (v === undefined) {
1221
+ if (!this._parts.hostname || this.is("IP")) {
1222
+ return "";
1223
+ }
1224
+ var t = this._parts.hostname.match(/\./g);
1225
+ if (t && t.length < 2) {
1226
+ return this._parts.hostname;
1227
+ }
1228
+ var end = this._parts.hostname.length - this.tld(build).length - 1;
1229
+ end = this._parts.hostname.lastIndexOf(".", end - 1) + 1;
1230
+ return this._parts.hostname.substring(end) || "";
1231
+ } else {
1232
+ if (!v) {
1233
+ throw new TypeError("cannot set domain empty");
1234
+ }
1235
+ if (v.indexOf(":") !== -1) {
1236
+ throw new TypeError("Domains cannot contain colons");
1237
+ }
1238
+ URI.ensureValidHostname(v, this._parts.protocol);
1239
+ if (!this._parts.hostname || this.is("IP")) {
1240
+ this._parts.hostname = v;
1241
+ } else {
1242
+ var replace = new RegExp(escapeRegEx(this.domain()) + "$");
1243
+ this._parts.hostname = this._parts.hostname.replace(replace, v);
1244
+ }
1245
+ this.build(!build);
1246
+ return this;
1247
+ }
1248
+ };
1249
+ p.tld = function (v, build) {
1250
+ if (this._parts.urn) {
1251
+ return v === undefined ? "" : this;
1252
+ }
1253
+ if (typeof v === "boolean") {
1254
+ build = v;
1255
+ v = undefined;
1256
+ }
1257
+ if (v === undefined) {
1258
+ if (!this._parts.hostname || this.is("IP")) {
1259
+ return "";
1260
+ }
1261
+ var pos = this._parts.hostname.lastIndexOf(".");
1262
+ var tld = this._parts.hostname.substring(pos + 1);
1263
+ if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
1264
+ return SLD.get(this._parts.hostname) || tld;
1265
+ }
1266
+ return tld;
1267
+ } else {
1268
+ var replace;
1269
+ if (!v) {
1270
+ throw new TypeError("cannot set TLD empty");
1271
+ } else if (v.match(/[^a-zA-Z0-9-]/)) {
1272
+ if (SLD && SLD.is(v)) {
1273
+ replace = new RegExp(escapeRegEx(this.tld()) + "$");
1274
+ this._parts.hostname = this._parts.hostname.replace(replace, v);
1275
+ } else {
1276
+ throw new TypeError("TLD \"" + v + "\" contains characters other than [A-Z0-9]");
1277
+ }
1278
+ } else if (!this._parts.hostname || this.is("IP")) {
1279
+ throw new ReferenceError("cannot set TLD on non-domain host");
1280
+ } else {
1281
+ replace = new RegExp(escapeRegEx(this.tld()) + "$");
1282
+ this._parts.hostname = this._parts.hostname.replace(replace, v);
1283
+ }
1284
+ this.build(!build);
1285
+ return this;
1286
+ }
1287
+ };
1288
+ p.directory = function (v, build) {
1289
+ if (this._parts.urn) {
1290
+ return v === undefined ? "" : this;
1291
+ }
1292
+ if (v === undefined || v === true) {
1293
+ if (!this._parts.path && !this._parts.hostname) {
1294
+ return "";
1295
+ }
1296
+ if (this._parts.path === "/") {
1297
+ return "/";
1298
+ }
1299
+ var end = this._parts.path.length - this.filename().length - 1;
1300
+ var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : "");
1301
+ return v ? URI.decodePath(res) : res;
1302
+ } else {
1303
+ var e = this._parts.path.length - this.filename().length;
1304
+ var directory = this._parts.path.substring(0, e);
1305
+ var replace = new RegExp("^" + escapeRegEx(directory));
1306
+ if (!this.is("relative")) {
1307
+ if (!v) {
1308
+ v = "/";
1309
+ }
1310
+ if (v.charAt(0) !== "/") {
1311
+ v = "/" + v;
1312
+ }
1313
+ }
1314
+ if (v && v.charAt(v.length - 1) !== "/") {
1315
+ v += "/";
1316
+ }
1317
+ v = URI.recodePath(v);
1318
+ this._parts.path = this._parts.path.replace(replace, v);
1319
+ this.build(!build);
1320
+ return this;
1321
+ }
1322
+ };
1323
+ p.filename = function (v, build) {
1324
+ if (this._parts.urn) {
1325
+ return v === undefined ? "" : this;
1326
+ }
1327
+ if (typeof v !== "string") {
1328
+ if (!this._parts.path || this._parts.path === "/") {
1329
+ return "";
1330
+ }
1331
+ var pos = this._parts.path.lastIndexOf("/");
1332
+ var res = this._parts.path.substring(pos + 1);
1333
+ return v ? URI.decodePathSegment(res) : res;
1334
+ } else {
1335
+ var mutatedDirectory = false;
1336
+ if (v.charAt(0) === "/") {
1337
+ v = v.substring(1);
1338
+ }
1339
+ if (v.match(/\.?\//)) {
1340
+ mutatedDirectory = true;
1341
+ }
1342
+ var replace = new RegExp(escapeRegEx(this.filename()) + "$");
1343
+ v = URI.recodePath(v);
1344
+ this._parts.path = this._parts.path.replace(replace, v);
1345
+ if (mutatedDirectory) {
1346
+ this.normalizePath(build);
1347
+ } else {
1348
+ this.build(!build);
1349
+ }
1350
+ return this;
1351
+ }
1352
+ };
1353
+ p.suffix = function (v, build) {
1354
+ if (this._parts.urn) {
1355
+ return v === undefined ? "" : this;
1356
+ }
1357
+ if (v === undefined || v === true) {
1358
+ if (!this._parts.path || this._parts.path === "/") {
1359
+ return "";
1360
+ }
1361
+ var filename = this.filename();
1362
+ var pos = filename.lastIndexOf(".");
1363
+ var s, res;
1364
+ if (pos === -1) {
1365
+ return "";
1366
+ }
1367
+ s = filename.substring(pos + 1);
1368
+ res = (/^[a-z0-9%]+$/i).test(s) ? s : "";
1369
+ return v ? URI.decodePathSegment(res) : res;
1370
+ } else {
1371
+ if (v.charAt(0) === ".") {
1372
+ v = v.substring(1);
1373
+ }
1374
+ var suffix = this.suffix();
1375
+ var replace;
1376
+ if (!suffix) {
1377
+ if (!v) {
1378
+ return this;
1379
+ }
1380
+ this._parts.path += "." + URI.recodePath(v);
1381
+ } else if (!v) {
1382
+ replace = new RegExp(escapeRegEx("." + suffix) + "$");
1383
+ } else {
1384
+ replace = new RegExp(escapeRegEx(suffix) + "$");
1385
+ }
1386
+ if (replace) {
1387
+ v = URI.recodePath(v);
1388
+ this._parts.path = this._parts.path.replace(replace, v);
1389
+ }
1390
+ this.build(!build);
1391
+ return this;
1392
+ }
1393
+ };
1394
+ p.segment = function (segment, v, build) {
1395
+ var separator = this._parts.urn ? ":" : "/";
1396
+ var path = this.path();
1397
+ var absolute = path.substring(0, 1) === "/";
1398
+ var segments = path.split(separator);
1399
+ if (segment !== undefined && typeof segment !== "number") {
1400
+ build = v;
1401
+ v = segment;
1402
+ segment = undefined;
1403
+ }
1404
+ if (segment !== undefined && typeof segment !== "number") {
1405
+ throw new Error("Bad segment \"" + segment + "\", must be 0-based integer");
1406
+ }
1407
+ if (absolute) {
1408
+ segments.shift();
1409
+ }
1410
+ if (segment < 0) {
1411
+ segment = Math.max(segments.length + segment, 0);
1412
+ }
1413
+ if (v === undefined) {
1414
+ return segment === undefined ? segments : segments[segment];
1415
+ } else if (segment === null || segments[segment] === undefined) {
1416
+ if (isArray(v)) {
1417
+ segments = [];
1418
+ for (var i = 0, l = v.length; i < l; i++) {
1419
+ if (!v[i].length && (!segments.length || !segments[segments.length - 1].length)) {
1420
+ continue;
1421
+ }
1422
+ if (segments.length && !segments[segments.length - 1].length) {
1423
+ segments.pop();
1424
+ }
1425
+ segments.push(trimSlashes(v[i]));
1426
+ }
1427
+ } else if (v || typeof v === "string") {
1428
+ v = trimSlashes(v);
1429
+ if (segments[segments.length - 1] === "") {
1430
+ segments[segments.length - 1] = v;
1431
+ } else {
1432
+ segments.push(v);
1433
+ }
1434
+ }
1435
+ } else {
1436
+ if (v) {
1437
+ segments[segment] = trimSlashes(v);
1438
+ } else {
1439
+ segments.splice(segment, 1);
1440
+ }
1441
+ }
1442
+ if (absolute) {
1443
+ segments.unshift("");
1444
+ }
1445
+ return this.path(segments.join(separator), build);
1446
+ };
1447
+ p.segmentCoded = function (segment, v, build) {
1448
+ var segments, i, l;
1449
+ if (typeof segment !== "number") {
1450
+ build = v;
1451
+ v = segment;
1452
+ segment = undefined;
1453
+ }
1454
+ if (v === undefined) {
1455
+ segments = this.segment(segment, v, build);
1456
+ if (!isArray(segments)) {
1457
+ segments = segments !== undefined ? URI.decode(segments) : undefined;
1458
+ } else {
1459
+ for ((i = 0, l = segments.length); i < l; i++) {
1460
+ segments[i] = URI.decode(segments[i]);
1461
+ }
1462
+ }
1463
+ return segments;
1464
+ }
1465
+ if (!isArray(v)) {
1466
+ v = typeof v === "string" || v instanceof String ? URI.encode(v) : v;
1467
+ } else {
1468
+ for ((i = 0, l = v.length); i < l; i++) {
1469
+ v[i] = URI.encode(v[i]);
1470
+ }
1471
+ }
1472
+ return this.segment(segment, v, build);
1473
+ };
1474
+ var q = p.query;
1475
+ p.query = function (v, build) {
1476
+ if (v === true) {
1477
+ return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1478
+ } else if (typeof v === "function") {
1479
+ var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1480
+ var result = v.call(this, data);
1481
+ this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
1482
+ this.build(!build);
1483
+ return this;
1484
+ } else if (v !== undefined && typeof v !== "string") {
1485
+ this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
1486
+ this.build(!build);
1487
+ return this;
1488
+ } else {
1489
+ return q.call(this, v, build);
1490
+ }
1491
+ };
1492
+ p.setQuery = function (name, value, build) {
1493
+ var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1494
+ if (typeof name === "string" || name instanceof String) {
1495
+ data[name] = value !== undefined ? value : null;
1496
+ } else if (typeof name === "object") {
1497
+ for (var key in name) {
1498
+ if (hasOwn$1.call(name, key)) {
1499
+ data[key] = name[key];
1500
+ }
1501
+ }
1502
+ } else {
1503
+ throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
1504
+ }
1505
+ this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
1506
+ if (typeof name !== "string") {
1507
+ build = value;
1508
+ }
1509
+ this.build(!build);
1510
+ return this;
1511
+ };
1512
+ p.addQuery = function (name, value, build) {
1513
+ var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1514
+ URI.addQuery(data, name, value === undefined ? null : value);
1515
+ this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
1516
+ if (typeof name !== "string") {
1517
+ build = value;
1518
+ }
1519
+ this.build(!build);
1520
+ return this;
1521
+ };
1522
+ p.removeQuery = function (name, value, build) {
1523
+ var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1524
+ URI.removeQuery(data, name, value);
1525
+ this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
1526
+ if (typeof name !== "string") {
1527
+ build = value;
1528
+ }
1529
+ this.build(!build);
1530
+ return this;
1531
+ };
1532
+ p.hasQuery = function (name, value, withinArray) {
1533
+ var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
1534
+ return URI.hasQuery(data, name, value, withinArray);
1535
+ };
1536
+ p.setSearch = p.setQuery;
1537
+ p.addSearch = p.addQuery;
1538
+ p.removeSearch = p.removeQuery;
1539
+ p.hasSearch = p.hasQuery;
1540
+ p.normalize = function () {
1541
+ if (this._parts.urn) {
1542
+ return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
1543
+ }
1544
+ return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
1545
+ };
1546
+ p.normalizeProtocol = function (build) {
1547
+ if (typeof this._parts.protocol === "string") {
1548
+ this._parts.protocol = this._parts.protocol.toLowerCase();
1549
+ this.build(!build);
1550
+ }
1551
+ return this;
1552
+ };
1553
+ p.normalizeHostname = function (build) {
1554
+ if (this._parts.hostname) {
1555
+ if (this.is("IDN") && punycode) {
1556
+ this._parts.hostname = punycode.toASCII(this._parts.hostname);
1557
+ } else if (this.is("IPv6") && IPv6) {
1558
+ this._parts.hostname = IPv6.best(this._parts.hostname);
1559
+ }
1560
+ this._parts.hostname = this._parts.hostname.toLowerCase();
1561
+ this.build(!build);
1562
+ }
1563
+ return this;
1564
+ };
1565
+ p.normalizePort = function (build) {
1566
+ if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
1567
+ this._parts.port = null;
1568
+ this.build(!build);
1569
+ }
1570
+ return this;
1571
+ };
1572
+ p.normalizePath = function (build) {
1573
+ var _path = this._parts.path;
1574
+ if (!_path) {
1575
+ return this;
1576
+ }
1577
+ if (this._parts.urn) {
1578
+ this._parts.path = URI.recodeUrnPath(this._parts.path);
1579
+ this.build(!build);
1580
+ return this;
1581
+ }
1582
+ if (this._parts.path === "/") {
1583
+ return this;
1584
+ }
1585
+ _path = URI.recodePath(_path);
1586
+ var _was_relative;
1587
+ var _leadingParents = "";
1588
+ var _parent, _pos;
1589
+ if (_path.charAt(0) !== "/") {
1590
+ _was_relative = true;
1591
+ _path = "/" + _path;
1592
+ }
1593
+ if (_path.slice(-3) === "/.." || _path.slice(-2) === "/.") {
1594
+ _path += "/";
1595
+ }
1596
+ _path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, "/").replace(/\/{2,}/g, "/");
1597
+ if (_was_relative) {
1598
+ _leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || "";
1599
+ if (_leadingParents) {
1600
+ _leadingParents = _leadingParents[0];
1601
+ }
1602
+ }
1603
+ while (true) {
1604
+ _parent = _path.search(/\/\.\.(\/|$)/);
1605
+ if (_parent === -1) {
1606
+ break;
1607
+ } else if (_parent === 0) {
1608
+ _path = _path.substring(3);
1609
+ continue;
1610
+ }
1611
+ _pos = _path.substring(0, _parent).lastIndexOf("/");
1612
+ if (_pos === -1) {
1613
+ _pos = _parent;
1614
+ }
1615
+ _path = _path.substring(0, _pos) + _path.substring(_parent + 3);
1616
+ }
1617
+ if (_was_relative && this.is("relative")) {
1618
+ _path = _leadingParents + _path.substring(1);
1619
+ }
1620
+ this._parts.path = _path;
1621
+ this.build(!build);
1622
+ return this;
1623
+ };
1624
+ p.normalizePathname = p.normalizePath;
1625
+ p.normalizeQuery = function (build) {
1626
+ if (typeof this._parts.query === "string") {
1627
+ if (!this._parts.query.length) {
1628
+ this._parts.query = null;
1629
+ } else {
1630
+ this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
1631
+ }
1632
+ this.build(!build);
1633
+ }
1634
+ return this;
1635
+ };
1636
+ p.normalizeFragment = function (build) {
1637
+ if (!this._parts.fragment) {
1638
+ this._parts.fragment = null;
1639
+ this.build(!build);
1640
+ }
1641
+ return this;
1642
+ };
1643
+ p.normalizeSearch = p.normalizeQuery;
1644
+ p.normalizeHash = p.normalizeFragment;
1645
+ p.iso8859 = function () {
1646
+ var e = URI.encode;
1647
+ var d = URI.decode;
1648
+ URI.encode = escape;
1649
+ URI.decode = decodeURIComponent;
1650
+ try {
1651
+ this.normalize();
1652
+ } finally {
1653
+ URI.encode = e;
1654
+ URI.decode = d;
1655
+ }
1656
+ return this;
1657
+ };
1658
+ p.unicode = function () {
1659
+ var e = URI.encode;
1660
+ var d = URI.decode;
1661
+ URI.encode = strictEncodeURIComponent;
1662
+ URI.decode = unescape;
1663
+ try {
1664
+ this.normalize();
1665
+ } finally {
1666
+ URI.encode = e;
1667
+ URI.decode = d;
1668
+ }
1669
+ return this;
1670
+ };
1671
+ p.readable = function () {
1672
+ var uri = this.clone();
1673
+ uri.username("").password("").normalize();
1674
+ var t = "";
1675
+ if (uri._parts.protocol) {
1676
+ t += uri._parts.protocol + "://";
1677
+ }
1678
+ if (uri._parts.hostname) {
1679
+ if (uri.is("punycode") && punycode) {
1680
+ t += punycode.toUnicode(uri._parts.hostname);
1681
+ if (uri._parts.port) {
1682
+ t += ":" + uri._parts.port;
1683
+ }
1684
+ } else {
1685
+ t += uri.host();
1686
+ }
1687
+ }
1688
+ if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== "/") {
1689
+ t += "/";
1690
+ }
1691
+ t += uri.path(true);
1692
+ if (uri._parts.query) {
1693
+ var q = "";
1694
+ for (var i = 0, qp = uri._parts.query.split("&"), l = qp.length; i < l; i++) {
1695
+ var kv = (qp[i] || "").split("=");
1696
+ q += "&" + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, "%26");
1697
+ if (kv[1] !== undefined) {
1698
+ q += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, "%26");
1699
+ }
1700
+ }
1701
+ t += "?" + q.substring(1);
1702
+ }
1703
+ t += URI.decodeQuery(uri.hash(), true);
1704
+ return t;
1705
+ };
1706
+ p.absoluteTo = function (base) {
1707
+ var resolved = this.clone();
1708
+ var properties = ["protocol", "username", "password", "hostname", "port"];
1709
+ var basedir, i, p;
1710
+ if (this._parts.urn) {
1711
+ throw new Error("URNs do not have any generally defined hierarchical components");
1712
+ }
1713
+ if (!(base instanceof URI)) {
1714
+ base = new URI(base);
1715
+ }
1716
+ if (resolved._parts.protocol) {
1717
+ return resolved;
1718
+ } else {
1719
+ resolved._parts.protocol = base._parts.protocol;
1720
+ }
1721
+ if (this._parts.hostname) {
1722
+ return resolved;
1723
+ }
1724
+ for (i = 0; p = properties[i]; i++) {
1725
+ resolved._parts[p] = base._parts[p];
1726
+ }
1727
+ if (!resolved._parts.path) {
1728
+ resolved._parts.path = base._parts.path;
1729
+ if (!resolved._parts.query) {
1730
+ resolved._parts.query = base._parts.query;
1731
+ }
1732
+ } else {
1733
+ if (resolved._parts.path.substring(-2) === "..") {
1734
+ resolved._parts.path += "/";
1735
+ }
1736
+ if (resolved.path().charAt(0) !== "/") {
1737
+ basedir = base.directory();
1738
+ basedir = basedir ? basedir : base.path().indexOf("/") === 0 ? "/" : "";
1739
+ resolved._parts.path = (basedir ? basedir + "/" : "") + resolved._parts.path;
1740
+ resolved.normalizePath();
1741
+ }
1742
+ }
1743
+ resolved.build();
1744
+ return resolved;
1745
+ };
1746
+ p.relativeTo = function (base) {
1747
+ var relative = this.clone().normalize();
1748
+ var relativeParts, baseParts, common, relativePath, basePath;
1749
+ if (relative._parts.urn) {
1750
+ throw new Error("URNs do not have any generally defined hierarchical components");
1751
+ }
1752
+ base = new URI(base).normalize();
1753
+ relativeParts = relative._parts;
1754
+ baseParts = base._parts;
1755
+ relativePath = relative.path();
1756
+ basePath = base.path();
1757
+ if (relativePath.charAt(0) !== "/") {
1758
+ throw new Error("URI is already relative");
1759
+ }
1760
+ if (basePath.charAt(0) !== "/") {
1761
+ throw new Error("Cannot calculate a URI relative to another relative URI");
1762
+ }
1763
+ if (relativeParts.protocol === baseParts.protocol) {
1764
+ relativeParts.protocol = null;
1765
+ }
1766
+ if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
1767
+ return relative.build();
1768
+ }
1769
+ if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
1770
+ return relative.build();
1771
+ }
1772
+ if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
1773
+ relativeParts.hostname = null;
1774
+ relativeParts.port = null;
1775
+ } else {
1776
+ return relative.build();
1777
+ }
1778
+ if (relativePath === basePath) {
1779
+ relativeParts.path = "";
1780
+ return relative.build();
1781
+ }
1782
+ common = URI.commonPath(relativePath, basePath);
1783
+ if (!common) {
1784
+ return relative.build();
1785
+ }
1786
+ var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, "").replace(/.*?\//g, "../");
1787
+ relativeParts.path = parents + relativeParts.path.substring(common.length) || "./";
1788
+ return relative.build();
1789
+ };
1790
+ p.equals = function (uri) {
1791
+ var one = this.clone();
1792
+ var two = new URI(uri);
1793
+ var one_map = {};
1794
+ var two_map = {};
1795
+ var checked = {};
1796
+ var one_query, two_query, key;
1797
+ one.normalize();
1798
+ two.normalize();
1799
+ if (one.toString() === two.toString()) {
1800
+ return true;
1801
+ }
1802
+ one_query = one.query();
1803
+ two_query = two.query();
1804
+ one.query("");
1805
+ two.query("");
1806
+ if (one.toString() !== two.toString()) {
1807
+ return false;
1808
+ }
1809
+ if (one_query.length !== two_query.length) {
1810
+ return false;
1811
+ }
1812
+ one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
1813
+ two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
1814
+ for (key in one_map) {
1815
+ if (hasOwn$1.call(one_map, key)) {
1816
+ if (!isArray(one_map[key])) {
1817
+ if (one_map[key] !== two_map[key]) {
1818
+ return false;
1819
+ }
1820
+ } else if (!arraysEqual(one_map[key], two_map[key])) {
1821
+ return false;
1822
+ }
1823
+ checked[key] = true;
1824
+ }
1825
+ }
1826
+ for (key in two_map) {
1827
+ if (hasOwn$1.call(two_map, key)) {
1828
+ if (!checked[key]) {
1829
+ return false;
1830
+ }
1831
+ }
1832
+ }
1833
+ return true;
1834
+ };
1835
+ p.preventInvalidHostname = function (v) {
1836
+ this._parts.preventInvalidHostname = !!v;
1837
+ return this;
1838
+ };
1839
+ p.duplicateQueryParameters = function (v) {
1840
+ this._parts.duplicateQueryParameters = !!v;
1841
+ return this;
1842
+ };
1843
+ p.escapeQuerySpace = function (v) {
1844
+ this._parts.escapeQuerySpace = !!v;
1845
+ return this;
1846
+ };
74
1847
 
75
1848
  var ApplyUtil = {
76
1849
  formatBundleName: function (sId, sBundleUrl) {