@magda/utils 6.0.0-alpha.7 → 6.0.0-alpha.9
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/dist/index-web.d.ts +1 -0
- package/dist/index-web.js +2491 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +24 -0
- package/package.json +2 -2
package/dist/index-web.js
CHANGED
|
@@ -2158,6 +2158,2428 @@ var require_merge = __commonJS({
|
|
|
2158
2158
|
}
|
|
2159
2159
|
});
|
|
2160
2160
|
|
|
2161
|
+
// ../../node_modules/urijs/src/punycode.js
|
|
2162
|
+
var require_punycode = __commonJS({
|
|
2163
|
+
"../../node_modules/urijs/src/punycode.js"(exports, module) {
|
|
2164
|
+
(function(root) {
|
|
2165
|
+
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
2166
|
+
var freeModule = typeof module == "object" && module && !module.nodeType && module;
|
|
2167
|
+
var freeGlobal = typeof global == "object" && global;
|
|
2168
|
+
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
|
|
2169
|
+
root = freeGlobal;
|
|
2170
|
+
}
|
|
2171
|
+
var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
|
|
2172
|
+
"overflow": "Overflow: input needs wider integers to process",
|
|
2173
|
+
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
2174
|
+
"invalid-input": "Invalid input"
|
|
2175
|
+
}, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
|
|
2176
|
+
function error(type) {
|
|
2177
|
+
throw new RangeError(errors[type]);
|
|
2178
|
+
}
|
|
2179
|
+
function map(array, fn) {
|
|
2180
|
+
var length = array.length;
|
|
2181
|
+
var result = [];
|
|
2182
|
+
while (length--) {
|
|
2183
|
+
result[length] = fn(array[length]);
|
|
2184
|
+
}
|
|
2185
|
+
return result;
|
|
2186
|
+
}
|
|
2187
|
+
function mapDomain(string, fn) {
|
|
2188
|
+
var parts = string.split("@");
|
|
2189
|
+
var result = "";
|
|
2190
|
+
if (parts.length > 1) {
|
|
2191
|
+
result = parts[0] + "@";
|
|
2192
|
+
string = parts[1];
|
|
2193
|
+
}
|
|
2194
|
+
string = string.replace(regexSeparators, ".");
|
|
2195
|
+
var labels = string.split(".");
|
|
2196
|
+
var encoded = map(labels, fn).join(".");
|
|
2197
|
+
return result + encoded;
|
|
2198
|
+
}
|
|
2199
|
+
function ucs2decode(string) {
|
|
2200
|
+
var output = [], counter = 0, length = string.length, value, extra;
|
|
2201
|
+
while (counter < length) {
|
|
2202
|
+
value = string.charCodeAt(counter++);
|
|
2203
|
+
if (value >= 55296 && value <= 56319 && counter < length) {
|
|
2204
|
+
extra = string.charCodeAt(counter++);
|
|
2205
|
+
if ((extra & 64512) == 56320) {
|
|
2206
|
+
output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
|
|
2207
|
+
} else {
|
|
2208
|
+
output.push(value);
|
|
2209
|
+
counter--;
|
|
2210
|
+
}
|
|
2211
|
+
} else {
|
|
2212
|
+
output.push(value);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return output;
|
|
2216
|
+
}
|
|
2217
|
+
function ucs2encode(array) {
|
|
2218
|
+
return map(array, function(value) {
|
|
2219
|
+
var output = "";
|
|
2220
|
+
if (value > 65535) {
|
|
2221
|
+
value -= 65536;
|
|
2222
|
+
output += stringFromCharCode(value >>> 10 & 1023 | 55296);
|
|
2223
|
+
value = 56320 | value & 1023;
|
|
2224
|
+
}
|
|
2225
|
+
output += stringFromCharCode(value);
|
|
2226
|
+
return output;
|
|
2227
|
+
}).join("");
|
|
2228
|
+
}
|
|
2229
|
+
function basicToDigit(codePoint) {
|
|
2230
|
+
if (codePoint - 48 < 10) {
|
|
2231
|
+
return codePoint - 22;
|
|
2232
|
+
}
|
|
2233
|
+
if (codePoint - 65 < 26) {
|
|
2234
|
+
return codePoint - 65;
|
|
2235
|
+
}
|
|
2236
|
+
if (codePoint - 97 < 26) {
|
|
2237
|
+
return codePoint - 97;
|
|
2238
|
+
}
|
|
2239
|
+
return base;
|
|
2240
|
+
}
|
|
2241
|
+
function digitToBasic(digit, flag) {
|
|
2242
|
+
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
2243
|
+
}
|
|
2244
|
+
function adapt(delta, numPoints, firstTime) {
|
|
2245
|
+
var k = 0;
|
|
2246
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
2247
|
+
delta += floor(delta / numPoints);
|
|
2248
|
+
for (; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
2249
|
+
delta = floor(delta / baseMinusTMin);
|
|
2250
|
+
}
|
|
2251
|
+
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
2252
|
+
}
|
|
2253
|
+
function decode(input) {
|
|
2254
|
+
var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT;
|
|
2255
|
+
basic = input.lastIndexOf(delimiter);
|
|
2256
|
+
if (basic < 0) {
|
|
2257
|
+
basic = 0;
|
|
2258
|
+
}
|
|
2259
|
+
for (j = 0; j < basic; ++j) {
|
|
2260
|
+
if (input.charCodeAt(j) >= 128) {
|
|
2261
|
+
error("not-basic");
|
|
2262
|
+
}
|
|
2263
|
+
output.push(input.charCodeAt(j));
|
|
2264
|
+
}
|
|
2265
|
+
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
2266
|
+
for (oldi = i, w = 1, k = base; ; k += base) {
|
|
2267
|
+
if (index >= inputLength) {
|
|
2268
|
+
error("invalid-input");
|
|
2269
|
+
}
|
|
2270
|
+
digit = basicToDigit(input.charCodeAt(index++));
|
|
2271
|
+
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
2272
|
+
error("overflow");
|
|
2273
|
+
}
|
|
2274
|
+
i += digit * w;
|
|
2275
|
+
t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
2276
|
+
if (digit < t) {
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
baseMinusT = base - t;
|
|
2280
|
+
if (w > floor(maxInt / baseMinusT)) {
|
|
2281
|
+
error("overflow");
|
|
2282
|
+
}
|
|
2283
|
+
w *= baseMinusT;
|
|
2284
|
+
}
|
|
2285
|
+
out = output.length + 1;
|
|
2286
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
|
2287
|
+
if (floor(i / out) > maxInt - n) {
|
|
2288
|
+
error("overflow");
|
|
2289
|
+
}
|
|
2290
|
+
n += floor(i / out);
|
|
2291
|
+
i %= out;
|
|
2292
|
+
output.splice(i++, 0, n);
|
|
2293
|
+
}
|
|
2294
|
+
return ucs2encode(output);
|
|
2295
|
+
}
|
|
2296
|
+
function encode(input) {
|
|
2297
|
+
var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
|
|
2298
|
+
input = ucs2decode(input);
|
|
2299
|
+
inputLength = input.length;
|
|
2300
|
+
n = initialN;
|
|
2301
|
+
delta = 0;
|
|
2302
|
+
bias = initialBias;
|
|
2303
|
+
for (j = 0; j < inputLength; ++j) {
|
|
2304
|
+
currentValue = input[j];
|
|
2305
|
+
if (currentValue < 128) {
|
|
2306
|
+
output.push(stringFromCharCode(currentValue));
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
handledCPCount = basicLength = output.length;
|
|
2310
|
+
if (basicLength) {
|
|
2311
|
+
output.push(delimiter);
|
|
2312
|
+
}
|
|
2313
|
+
while (handledCPCount < inputLength) {
|
|
2314
|
+
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
2315
|
+
currentValue = input[j];
|
|
2316
|
+
if (currentValue >= n && currentValue < m) {
|
|
2317
|
+
m = currentValue;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
handledCPCountPlusOne = handledCPCount + 1;
|
|
2321
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
2322
|
+
error("overflow");
|
|
2323
|
+
}
|
|
2324
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
2325
|
+
n = m;
|
|
2326
|
+
for (j = 0; j < inputLength; ++j) {
|
|
2327
|
+
currentValue = input[j];
|
|
2328
|
+
if (currentValue < n && ++delta > maxInt) {
|
|
2329
|
+
error("overflow");
|
|
2330
|
+
}
|
|
2331
|
+
if (currentValue == n) {
|
|
2332
|
+
for (q = delta, k = base; ; k += base) {
|
|
2333
|
+
t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
2334
|
+
if (q < t) {
|
|
2335
|
+
break;
|
|
2336
|
+
}
|
|
2337
|
+
qMinusT = q - t;
|
|
2338
|
+
baseMinusT = base - t;
|
|
2339
|
+
output.push(
|
|
2340
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
2341
|
+
);
|
|
2342
|
+
q = floor(qMinusT / baseMinusT);
|
|
2343
|
+
}
|
|
2344
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
2345
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
2346
|
+
delta = 0;
|
|
2347
|
+
++handledCPCount;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
++delta;
|
|
2351
|
+
++n;
|
|
2352
|
+
}
|
|
2353
|
+
return output.join("");
|
|
2354
|
+
}
|
|
2355
|
+
function toUnicode(input) {
|
|
2356
|
+
return mapDomain(input, function(string) {
|
|
2357
|
+
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
function toASCII(input) {
|
|
2361
|
+
return mapDomain(input, function(string) {
|
|
2362
|
+
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
punycode = {
|
|
2366
|
+
/**
|
|
2367
|
+
* A string representing the current Punycode.js version number.
|
|
2368
|
+
* @memberOf punycode
|
|
2369
|
+
* @type String
|
|
2370
|
+
*/
|
|
2371
|
+
"version": "1.3.2",
|
|
2372
|
+
/**
|
|
2373
|
+
* An object of methods to convert from JavaScript's internal character
|
|
2374
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
2375
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
2376
|
+
* @memberOf punycode
|
|
2377
|
+
* @type Object
|
|
2378
|
+
*/
|
|
2379
|
+
"ucs2": {
|
|
2380
|
+
"decode": ucs2decode,
|
|
2381
|
+
"encode": ucs2encode
|
|
2382
|
+
},
|
|
2383
|
+
"decode": decode,
|
|
2384
|
+
"encode": encode,
|
|
2385
|
+
"toASCII": toASCII,
|
|
2386
|
+
"toUnicode": toUnicode
|
|
2387
|
+
};
|
|
2388
|
+
if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
|
|
2389
|
+
define("punycode", function() {
|
|
2390
|
+
return punycode;
|
|
2391
|
+
});
|
|
2392
|
+
} else if (freeExports && freeModule) {
|
|
2393
|
+
if (module.exports == freeExports) {
|
|
2394
|
+
freeModule.exports = punycode;
|
|
2395
|
+
} else {
|
|
2396
|
+
for (key in punycode) {
|
|
2397
|
+
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
} else {
|
|
2401
|
+
root.punycode = punycode;
|
|
2402
|
+
}
|
|
2403
|
+
})(exports);
|
|
2404
|
+
}
|
|
2405
|
+
});
|
|
2406
|
+
|
|
2407
|
+
// ../../node_modules/urijs/src/IPv6.js
|
|
2408
|
+
var require_IPv6 = __commonJS({
|
|
2409
|
+
"../../node_modules/urijs/src/IPv6.js"(exports, module) {
|
|
2410
|
+
(function(root, factory) {
|
|
2411
|
+
"use strict";
|
|
2412
|
+
if (typeof module === "object" && module.exports) {
|
|
2413
|
+
module.exports = factory();
|
|
2414
|
+
} else if (typeof define === "function" && define.amd) {
|
|
2415
|
+
define(factory);
|
|
2416
|
+
} else {
|
|
2417
|
+
root.IPv6 = factory(root);
|
|
2418
|
+
}
|
|
2419
|
+
})(exports, function(root) {
|
|
2420
|
+
"use strict";
|
|
2421
|
+
var _IPv6 = root && root.IPv6;
|
|
2422
|
+
function bestPresentation(address) {
|
|
2423
|
+
var _address = address.toLowerCase();
|
|
2424
|
+
var segments = _address.split(":");
|
|
2425
|
+
var length = segments.length;
|
|
2426
|
+
var total = 8;
|
|
2427
|
+
if (segments[0] === "" && segments[1] === "" && segments[2] === "") {
|
|
2428
|
+
segments.shift();
|
|
2429
|
+
segments.shift();
|
|
2430
|
+
} else if (segments[0] === "" && segments[1] === "") {
|
|
2431
|
+
segments.shift();
|
|
2432
|
+
} else if (segments[length - 1] === "" && segments[length - 2] === "") {
|
|
2433
|
+
segments.pop();
|
|
2434
|
+
}
|
|
2435
|
+
length = segments.length;
|
|
2436
|
+
if (segments[length - 1].indexOf(".") !== -1) {
|
|
2437
|
+
total = 7;
|
|
2438
|
+
}
|
|
2439
|
+
var pos;
|
|
2440
|
+
for (pos = 0; pos < length; pos++) {
|
|
2441
|
+
if (segments[pos] === "") {
|
|
2442
|
+
break;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
if (pos < total) {
|
|
2446
|
+
segments.splice(pos, 1, "0000");
|
|
2447
|
+
while (segments.length < total) {
|
|
2448
|
+
segments.splice(pos, 0, "0000");
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
var _segments;
|
|
2452
|
+
for (var i = 0; i < total; i++) {
|
|
2453
|
+
_segments = segments[i].split("");
|
|
2454
|
+
for (var j = 0; j < 3; j++) {
|
|
2455
|
+
if (_segments[0] === "0" && _segments.length > 1) {
|
|
2456
|
+
_segments.splice(0, 1);
|
|
2457
|
+
} else {
|
|
2458
|
+
break;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
segments[i] = _segments.join("");
|
|
2462
|
+
}
|
|
2463
|
+
var best = -1;
|
|
2464
|
+
var _best = 0;
|
|
2465
|
+
var _current = 0;
|
|
2466
|
+
var current = -1;
|
|
2467
|
+
var inzeroes = false;
|
|
2468
|
+
for (i = 0; i < total; i++) {
|
|
2469
|
+
if (inzeroes) {
|
|
2470
|
+
if (segments[i] === "0") {
|
|
2471
|
+
_current += 1;
|
|
2472
|
+
} else {
|
|
2473
|
+
inzeroes = false;
|
|
2474
|
+
if (_current > _best) {
|
|
2475
|
+
best = current;
|
|
2476
|
+
_best = _current;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
} else {
|
|
2480
|
+
if (segments[i] === "0") {
|
|
2481
|
+
inzeroes = true;
|
|
2482
|
+
current = i;
|
|
2483
|
+
_current = 1;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
if (_current > _best) {
|
|
2488
|
+
best = current;
|
|
2489
|
+
_best = _current;
|
|
2490
|
+
}
|
|
2491
|
+
if (_best > 1) {
|
|
2492
|
+
segments.splice(best, _best, "");
|
|
2493
|
+
}
|
|
2494
|
+
length = segments.length;
|
|
2495
|
+
var result = "";
|
|
2496
|
+
if (segments[0] === "") {
|
|
2497
|
+
result = ":";
|
|
2498
|
+
}
|
|
2499
|
+
for (i = 0; i < length; i++) {
|
|
2500
|
+
result += segments[i];
|
|
2501
|
+
if (i === length - 1) {
|
|
2502
|
+
break;
|
|
2503
|
+
}
|
|
2504
|
+
result += ":";
|
|
2505
|
+
}
|
|
2506
|
+
if (segments[length - 1] === "") {
|
|
2507
|
+
result += ":";
|
|
2508
|
+
}
|
|
2509
|
+
return result;
|
|
2510
|
+
}
|
|
2511
|
+
function noConflict() {
|
|
2512
|
+
if (root.IPv6 === this) {
|
|
2513
|
+
root.IPv6 = _IPv6;
|
|
2514
|
+
}
|
|
2515
|
+
return this;
|
|
2516
|
+
}
|
|
2517
|
+
return {
|
|
2518
|
+
best: bestPresentation,
|
|
2519
|
+
noConflict
|
|
2520
|
+
};
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
});
|
|
2524
|
+
|
|
2525
|
+
// ../../node_modules/urijs/src/SecondLevelDomains.js
|
|
2526
|
+
var require_SecondLevelDomains = __commonJS({
|
|
2527
|
+
"../../node_modules/urijs/src/SecondLevelDomains.js"(exports, module) {
|
|
2528
|
+
(function(root, factory) {
|
|
2529
|
+
"use strict";
|
|
2530
|
+
if (typeof module === "object" && module.exports) {
|
|
2531
|
+
module.exports = factory();
|
|
2532
|
+
} else if (typeof define === "function" && define.amd) {
|
|
2533
|
+
define(factory);
|
|
2534
|
+
} else {
|
|
2535
|
+
root.SecondLevelDomains = factory(root);
|
|
2536
|
+
}
|
|
2537
|
+
})(exports, function(root) {
|
|
2538
|
+
"use strict";
|
|
2539
|
+
var _SecondLevelDomains = root && root.SecondLevelDomains;
|
|
2540
|
+
var SLD = {
|
|
2541
|
+
// list of known Second Level Domains
|
|
2542
|
+
// converted list of SLDs from https://github.com/gavingmiller/second-level-domains
|
|
2543
|
+
// ----
|
|
2544
|
+
// publicsuffix.org is more current and actually used by a couple of browsers internally.
|
|
2545
|
+
// downside is it also contains domains like "dyndns.org" - which is fine for the security
|
|
2546
|
+
// issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js
|
|
2547
|
+
// ----
|
|
2548
|
+
list: {
|
|
2549
|
+
"ac": " com gov mil net org ",
|
|
2550
|
+
"ae": " ac co gov mil name net org pro sch ",
|
|
2551
|
+
"af": " com edu gov net org ",
|
|
2552
|
+
"al": " com edu gov mil net org ",
|
|
2553
|
+
"ao": " co ed gv it og pb ",
|
|
2554
|
+
"ar": " com edu gob gov int mil net org tur ",
|
|
2555
|
+
"at": " ac co gv or ",
|
|
2556
|
+
"au": " asn com csiro edu gov id net org ",
|
|
2557
|
+
"ba": " co com edu gov mil net org rs unbi unmo unsa untz unze ",
|
|
2558
|
+
"bb": " biz co com edu gov info net org store tv ",
|
|
2559
|
+
"bh": " biz cc com edu gov info net org ",
|
|
2560
|
+
"bn": " com edu gov net org ",
|
|
2561
|
+
"bo": " com edu gob gov int mil net org tv ",
|
|
2562
|
+
"br": " adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",
|
|
2563
|
+
"bs": " com edu gov net org ",
|
|
2564
|
+
"bz": " du et om ov rg ",
|
|
2565
|
+
"ca": " ab bc mb nb nf nl ns nt nu on pe qc sk yk ",
|
|
2566
|
+
"ck": " biz co edu gen gov info net org ",
|
|
2567
|
+
"cn": " ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",
|
|
2568
|
+
"co": " com edu gov mil net nom org ",
|
|
2569
|
+
"cr": " ac c co ed fi go or sa ",
|
|
2570
|
+
"cy": " ac biz com ekloges gov ltd name net org parliament press pro tm ",
|
|
2571
|
+
"do": " art com edu gob gov mil net org sld web ",
|
|
2572
|
+
"dz": " art asso com edu gov net org pol ",
|
|
2573
|
+
"ec": " com edu fin gov info med mil net org pro ",
|
|
2574
|
+
"eg": " com edu eun gov mil name net org sci ",
|
|
2575
|
+
"er": " com edu gov ind mil net org rochest w ",
|
|
2576
|
+
"es": " com edu gob nom org ",
|
|
2577
|
+
"et": " biz com edu gov info name net org ",
|
|
2578
|
+
"fj": " ac biz com info mil name net org pro ",
|
|
2579
|
+
"fk": " ac co gov net nom org ",
|
|
2580
|
+
"fr": " asso com f gouv nom prd presse tm ",
|
|
2581
|
+
"gg": " co net org ",
|
|
2582
|
+
"gh": " com edu gov mil org ",
|
|
2583
|
+
"gn": " ac com gov net org ",
|
|
2584
|
+
"gr": " com edu gov mil net org ",
|
|
2585
|
+
"gt": " com edu gob ind mil net org ",
|
|
2586
|
+
"gu": " com edu gov net org ",
|
|
2587
|
+
"hk": " com edu gov idv net org ",
|
|
2588
|
+
"hu": " 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",
|
|
2589
|
+
"id": " ac co go mil net or sch web ",
|
|
2590
|
+
"il": " ac co gov idf k12 muni net org ",
|
|
2591
|
+
"in": " ac co edu ernet firm gen gov i ind mil net nic org res ",
|
|
2592
|
+
"iq": " com edu gov i mil net org ",
|
|
2593
|
+
"ir": " ac co dnssec gov i id net org sch ",
|
|
2594
|
+
"it": " edu gov ",
|
|
2595
|
+
"je": " co net org ",
|
|
2596
|
+
"jo": " com edu gov mil name net org sch ",
|
|
2597
|
+
"jp": " ac ad co ed go gr lg ne or ",
|
|
2598
|
+
"ke": " ac co go info me mobi ne or sc ",
|
|
2599
|
+
"kh": " com edu gov mil net org per ",
|
|
2600
|
+
"ki": " biz com de edu gov info mob net org tel ",
|
|
2601
|
+
"km": " asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",
|
|
2602
|
+
"kn": " edu gov net org ",
|
|
2603
|
+
"kr": " ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",
|
|
2604
|
+
"kw": " com edu gov net org ",
|
|
2605
|
+
"ky": " com edu gov net org ",
|
|
2606
|
+
"kz": " com edu gov mil net org ",
|
|
2607
|
+
"lb": " com edu gov net org ",
|
|
2608
|
+
"lk": " assn com edu gov grp hotel int ltd net ngo org sch soc web ",
|
|
2609
|
+
"lr": " com edu gov net org ",
|
|
2610
|
+
"lv": " asn com conf edu gov id mil net org ",
|
|
2611
|
+
"ly": " com edu gov id med net org plc sch ",
|
|
2612
|
+
"ma": " ac co gov m net org press ",
|
|
2613
|
+
"mc": " asso tm ",
|
|
2614
|
+
"me": " ac co edu gov its net org priv ",
|
|
2615
|
+
"mg": " com edu gov mil nom org prd tm ",
|
|
2616
|
+
"mk": " com edu gov inf name net org pro ",
|
|
2617
|
+
"ml": " com edu gov net org presse ",
|
|
2618
|
+
"mn": " edu gov org ",
|
|
2619
|
+
"mo": " com edu gov net org ",
|
|
2620
|
+
"mt": " com edu gov net org ",
|
|
2621
|
+
"mv": " aero biz com coop edu gov info int mil museum name net org pro ",
|
|
2622
|
+
"mw": " ac co com coop edu gov int museum net org ",
|
|
2623
|
+
"mx": " com edu gob net org ",
|
|
2624
|
+
"my": " com edu gov mil name net org sch ",
|
|
2625
|
+
"nf": " arts com firm info net other per rec store web ",
|
|
2626
|
+
"ng": " biz com edu gov mil mobi name net org sch ",
|
|
2627
|
+
"ni": " ac co com edu gob mil net nom org ",
|
|
2628
|
+
"np": " com edu gov mil net org ",
|
|
2629
|
+
"nr": " biz com edu gov info net org ",
|
|
2630
|
+
"om": " ac biz co com edu gov med mil museum net org pro sch ",
|
|
2631
|
+
"pe": " com edu gob mil net nom org sld ",
|
|
2632
|
+
"ph": " com edu gov i mil net ngo org ",
|
|
2633
|
+
"pk": " biz com edu fam gob gok gon gop gos gov net org web ",
|
|
2634
|
+
"pl": " art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",
|
|
2635
|
+
"pr": " ac biz com edu est gov info isla name net org pro prof ",
|
|
2636
|
+
"ps": " com edu gov net org plo sec ",
|
|
2637
|
+
"pw": " belau co ed go ne or ",
|
|
2638
|
+
"ro": " arts com firm info nom nt org rec store tm www ",
|
|
2639
|
+
"rs": " ac co edu gov in org ",
|
|
2640
|
+
"sb": " com edu gov net org ",
|
|
2641
|
+
"sc": " com edu gov net org ",
|
|
2642
|
+
"sh": " co com edu gov net nom org ",
|
|
2643
|
+
"sl": " com edu gov net org ",
|
|
2644
|
+
"st": " co com consulado edu embaixada gov mil net org principe saotome store ",
|
|
2645
|
+
"sv": " com edu gob org red ",
|
|
2646
|
+
"sz": " ac co org ",
|
|
2647
|
+
"tr": " av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",
|
|
2648
|
+
"tt": " aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",
|
|
2649
|
+
"tw": " club com ebiz edu game gov idv mil net org ",
|
|
2650
|
+
"mu": " ac co com gov net or org ",
|
|
2651
|
+
"mz": " ac co edu gov org ",
|
|
2652
|
+
"na": " co com ",
|
|
2653
|
+
"nz": " ac co cri geek gen govt health iwi maori mil net org parliament school ",
|
|
2654
|
+
"pa": " abo ac com edu gob ing med net nom org sld ",
|
|
2655
|
+
"pt": " com edu gov int net nome org publ ",
|
|
2656
|
+
"py": " com edu gov mil net org ",
|
|
2657
|
+
"qa": " com edu gov mil net org ",
|
|
2658
|
+
"re": " asso com nom ",
|
|
2659
|
+
"ru": " ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",
|
|
2660
|
+
"rw": " ac co com edu gouv gov int mil net ",
|
|
2661
|
+
"sa": " com edu gov med net org pub sch ",
|
|
2662
|
+
"sd": " com edu gov info med net org tv ",
|
|
2663
|
+
"se": " a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",
|
|
2664
|
+
"sg": " com edu gov idn net org per ",
|
|
2665
|
+
"sn": " art com edu gouv org perso univ ",
|
|
2666
|
+
"sy": " com edu gov mil net news org ",
|
|
2667
|
+
"th": " ac co go in mi net or ",
|
|
2668
|
+
"tj": " ac biz co com edu go gov info int mil name net nic org test web ",
|
|
2669
|
+
"tn": " agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",
|
|
2670
|
+
"tz": " ac co go ne or ",
|
|
2671
|
+
"ua": " biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",
|
|
2672
|
+
"ug": " ac co go ne or org sc ",
|
|
2673
|
+
"uk": " ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",
|
|
2674
|
+
"us": " dni fed isa kids nsn ",
|
|
2675
|
+
"uy": " com edu gub mil net org ",
|
|
2676
|
+
"ve": " co com edu gob info mil net org web ",
|
|
2677
|
+
"vi": " co com k12 net org ",
|
|
2678
|
+
"vn": " ac biz com edu gov health info int name net org pro ",
|
|
2679
|
+
"ye": " co com gov ltd me net org plc ",
|
|
2680
|
+
"yu": " ac co edu gov org ",
|
|
2681
|
+
"za": " ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",
|
|
2682
|
+
"zm": " ac co com edu gov net org sch ",
|
|
2683
|
+
// https://en.wikipedia.org/wiki/CentralNic#Second-level_domains
|
|
2684
|
+
"com": "ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",
|
|
2685
|
+
"net": "gb jp se uk ",
|
|
2686
|
+
"org": "ae",
|
|
2687
|
+
"de": "com "
|
|
2688
|
+
},
|
|
2689
|
+
// gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost
|
|
2690
|
+
// in both performance and memory footprint. No initialization required.
|
|
2691
|
+
// http://jsperf.com/uri-js-sld-regex-vs-binary-search/4
|
|
2692
|
+
// Following methods use lastIndexOf() rather than array.split() in order
|
|
2693
|
+
// to avoid any memory allocations.
|
|
2694
|
+
has: function(domain) {
|
|
2695
|
+
var tldOffset = domain.lastIndexOf(".");
|
|
2696
|
+
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
|
|
2697
|
+
return false;
|
|
2698
|
+
}
|
|
2699
|
+
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
|
|
2700
|
+
if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
|
|
2701
|
+
return false;
|
|
2702
|
+
}
|
|
2703
|
+
var sldList = SLD.list[domain.slice(tldOffset + 1)];
|
|
2704
|
+
if (!sldList) {
|
|
2705
|
+
return false;
|
|
2706
|
+
}
|
|
2707
|
+
return sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") >= 0;
|
|
2708
|
+
},
|
|
2709
|
+
is: function(domain) {
|
|
2710
|
+
var tldOffset = domain.lastIndexOf(".");
|
|
2711
|
+
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
|
|
2712
|
+
return false;
|
|
2713
|
+
}
|
|
2714
|
+
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
|
|
2715
|
+
if (sldOffset >= 0) {
|
|
2716
|
+
return false;
|
|
2717
|
+
}
|
|
2718
|
+
var sldList = SLD.list[domain.slice(tldOffset + 1)];
|
|
2719
|
+
if (!sldList) {
|
|
2720
|
+
return false;
|
|
2721
|
+
}
|
|
2722
|
+
return sldList.indexOf(" " + domain.slice(0, tldOffset) + " ") >= 0;
|
|
2723
|
+
},
|
|
2724
|
+
get: function(domain) {
|
|
2725
|
+
var tldOffset = domain.lastIndexOf(".");
|
|
2726
|
+
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
|
|
2727
|
+
return null;
|
|
2728
|
+
}
|
|
2729
|
+
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
|
|
2730
|
+
if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
|
|
2731
|
+
return null;
|
|
2732
|
+
}
|
|
2733
|
+
var sldList = SLD.list[domain.slice(tldOffset + 1)];
|
|
2734
|
+
if (!sldList) {
|
|
2735
|
+
return null;
|
|
2736
|
+
}
|
|
2737
|
+
if (sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") < 0) {
|
|
2738
|
+
return null;
|
|
2739
|
+
}
|
|
2740
|
+
return domain.slice(sldOffset + 1);
|
|
2741
|
+
},
|
|
2742
|
+
noConflict: function() {
|
|
2743
|
+
if (root.SecondLevelDomains === this) {
|
|
2744
|
+
root.SecondLevelDomains = _SecondLevelDomains;
|
|
2745
|
+
}
|
|
2746
|
+
return this;
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2749
|
+
return SLD;
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
});
|
|
2753
|
+
|
|
2754
|
+
// ../../node_modules/urijs/src/URI.js
|
|
2755
|
+
var require_URI = __commonJS({
|
|
2756
|
+
"../../node_modules/urijs/src/URI.js"(exports, module) {
|
|
2757
|
+
(function(root, factory) {
|
|
2758
|
+
"use strict";
|
|
2759
|
+
if (typeof module === "object" && module.exports) {
|
|
2760
|
+
module.exports = factory(require_punycode(), require_IPv6(), require_SecondLevelDomains());
|
|
2761
|
+
} else if (typeof define === "function" && define.amd) {
|
|
2762
|
+
define(["./punycode", "./IPv6", "./SecondLevelDomains"], factory);
|
|
2763
|
+
} else {
|
|
2764
|
+
root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root);
|
|
2765
|
+
}
|
|
2766
|
+
})(exports, function(punycode, IPv6, SLD, root) {
|
|
2767
|
+
"use strict";
|
|
2768
|
+
var _URI = root && root.URI;
|
|
2769
|
+
function URI(url, base) {
|
|
2770
|
+
var _urlSupplied = arguments.length >= 1;
|
|
2771
|
+
var _baseSupplied = arguments.length >= 2;
|
|
2772
|
+
if (!(this instanceof URI)) {
|
|
2773
|
+
if (_urlSupplied) {
|
|
2774
|
+
if (_baseSupplied) {
|
|
2775
|
+
return new URI(url, base);
|
|
2776
|
+
}
|
|
2777
|
+
return new URI(url);
|
|
2778
|
+
}
|
|
2779
|
+
return new URI();
|
|
2780
|
+
}
|
|
2781
|
+
if (url === void 0) {
|
|
2782
|
+
if (_urlSupplied) {
|
|
2783
|
+
throw new TypeError("undefined is not a valid argument for URI");
|
|
2784
|
+
}
|
|
2785
|
+
if (typeof location !== "undefined") {
|
|
2786
|
+
url = location.href + "";
|
|
2787
|
+
} else {
|
|
2788
|
+
url = "";
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
if (url === null) {
|
|
2792
|
+
if (_urlSupplied) {
|
|
2793
|
+
throw new TypeError("null is not a valid argument for URI");
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
this.href(url);
|
|
2797
|
+
if (base !== void 0) {
|
|
2798
|
+
return this.absoluteTo(base);
|
|
2799
|
+
}
|
|
2800
|
+
return this;
|
|
2801
|
+
}
|
|
2802
|
+
function isInteger(value) {
|
|
2803
|
+
return /^[0-9]+$/.test(value);
|
|
2804
|
+
}
|
|
2805
|
+
URI.version = "1.19.11";
|
|
2806
|
+
var p = URI.prototype;
|
|
2807
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
2808
|
+
function escapeRegEx(string) {
|
|
2809
|
+
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
|
|
2810
|
+
}
|
|
2811
|
+
function getType(value) {
|
|
2812
|
+
if (value === void 0) {
|
|
2813
|
+
return "Undefined";
|
|
2814
|
+
}
|
|
2815
|
+
return String(Object.prototype.toString.call(value)).slice(8, -1);
|
|
2816
|
+
}
|
|
2817
|
+
function isArray(obj) {
|
|
2818
|
+
return getType(obj) === "Array";
|
|
2819
|
+
}
|
|
2820
|
+
function filterArrayValues(data, value) {
|
|
2821
|
+
var lookup = {};
|
|
2822
|
+
var i, length;
|
|
2823
|
+
if (getType(value) === "RegExp") {
|
|
2824
|
+
lookup = null;
|
|
2825
|
+
} else if (isArray(value)) {
|
|
2826
|
+
for (i = 0, length = value.length; i < length; i++) {
|
|
2827
|
+
lookup[value[i]] = true;
|
|
2828
|
+
}
|
|
2829
|
+
} else {
|
|
2830
|
+
lookup[value] = true;
|
|
2831
|
+
}
|
|
2832
|
+
for (i = 0, length = data.length; i < length; i++) {
|
|
2833
|
+
var _match = lookup && lookup[data[i]] !== void 0 || !lookup && value.test(data[i]);
|
|
2834
|
+
if (_match) {
|
|
2835
|
+
data.splice(i, 1);
|
|
2836
|
+
length--;
|
|
2837
|
+
i--;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
return data;
|
|
2841
|
+
}
|
|
2842
|
+
function arrayContains(list, value) {
|
|
2843
|
+
var i, length;
|
|
2844
|
+
if (isArray(value)) {
|
|
2845
|
+
for (i = 0, length = value.length; i < length; i++) {
|
|
2846
|
+
if (!arrayContains(list, value[i])) {
|
|
2847
|
+
return false;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
return true;
|
|
2851
|
+
}
|
|
2852
|
+
var _type = getType(value);
|
|
2853
|
+
for (i = 0, length = list.length; i < length; i++) {
|
|
2854
|
+
if (_type === "RegExp") {
|
|
2855
|
+
if (typeof list[i] === "string" && list[i].match(value)) {
|
|
2856
|
+
return true;
|
|
2857
|
+
}
|
|
2858
|
+
} else if (list[i] === value) {
|
|
2859
|
+
return true;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
return false;
|
|
2863
|
+
}
|
|
2864
|
+
function arraysEqual(one, two) {
|
|
2865
|
+
if (!isArray(one) || !isArray(two)) {
|
|
2866
|
+
return false;
|
|
2867
|
+
}
|
|
2868
|
+
if (one.length !== two.length) {
|
|
2869
|
+
return false;
|
|
2870
|
+
}
|
|
2871
|
+
one.sort();
|
|
2872
|
+
two.sort();
|
|
2873
|
+
for (var i = 0, l = one.length; i < l; i++) {
|
|
2874
|
+
if (one[i] !== two[i]) {
|
|
2875
|
+
return false;
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
return true;
|
|
2879
|
+
}
|
|
2880
|
+
function trimSlashes(text) {
|
|
2881
|
+
var trim_expression = /^\/+|\/+$/g;
|
|
2882
|
+
return text.replace(trim_expression, "");
|
|
2883
|
+
}
|
|
2884
|
+
URI._parts = function() {
|
|
2885
|
+
return {
|
|
2886
|
+
protocol: null,
|
|
2887
|
+
username: null,
|
|
2888
|
+
password: null,
|
|
2889
|
+
hostname: null,
|
|
2890
|
+
urn: null,
|
|
2891
|
+
port: null,
|
|
2892
|
+
path: null,
|
|
2893
|
+
query: null,
|
|
2894
|
+
fragment: null,
|
|
2895
|
+
// state
|
|
2896
|
+
preventInvalidHostname: URI.preventInvalidHostname,
|
|
2897
|
+
duplicateQueryParameters: URI.duplicateQueryParameters,
|
|
2898
|
+
escapeQuerySpace: URI.escapeQuerySpace
|
|
2899
|
+
};
|
|
2900
|
+
};
|
|
2901
|
+
URI.preventInvalidHostname = false;
|
|
2902
|
+
URI.duplicateQueryParameters = false;
|
|
2903
|
+
URI.escapeQuerySpace = true;
|
|
2904
|
+
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
|
|
2905
|
+
URI.idn_expression = /[^a-z0-9\._-]/i;
|
|
2906
|
+
URI.punycode_expression = /(xn--)/i;
|
|
2907
|
+
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
2908
|
+
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*$/;
|
|
2909
|
+
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;
|
|
2910
|
+
URI.findUri = {
|
|
2911
|
+
// valid "scheme://" or "www."
|
|
2912
|
+
start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
|
|
2913
|
+
// everything up to the next whitespace
|
|
2914
|
+
end: /[\s\r\n]|$/,
|
|
2915
|
+
// trim trailing punctuation captured by end RegExp
|
|
2916
|
+
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
|
|
2917
|
+
// balanced parens inclusion (), [], {}, <>
|
|
2918
|
+
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g
|
|
2919
|
+
};
|
|
2920
|
+
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
|
2921
|
+
URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g;
|
|
2922
|
+
URI.defaultPorts = {
|
|
2923
|
+
http: "80",
|
|
2924
|
+
https: "443",
|
|
2925
|
+
ftp: "21",
|
|
2926
|
+
gopher: "70",
|
|
2927
|
+
ws: "80",
|
|
2928
|
+
wss: "443"
|
|
2929
|
+
};
|
|
2930
|
+
URI.hostProtocols = [
|
|
2931
|
+
"http",
|
|
2932
|
+
"https"
|
|
2933
|
+
];
|
|
2934
|
+
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/;
|
|
2935
|
+
URI.domAttributes = {
|
|
2936
|
+
"a": "href",
|
|
2937
|
+
"blockquote": "cite",
|
|
2938
|
+
"link": "href",
|
|
2939
|
+
"base": "href",
|
|
2940
|
+
"script": "src",
|
|
2941
|
+
"form": "action",
|
|
2942
|
+
"img": "src",
|
|
2943
|
+
"area": "href",
|
|
2944
|
+
"iframe": "src",
|
|
2945
|
+
"embed": "src",
|
|
2946
|
+
"source": "src",
|
|
2947
|
+
"track": "src",
|
|
2948
|
+
"input": "src",
|
|
2949
|
+
// but only if type="image"
|
|
2950
|
+
"audio": "src",
|
|
2951
|
+
"video": "src"
|
|
2952
|
+
};
|
|
2953
|
+
URI.getDomAttribute = function(node) {
|
|
2954
|
+
if (!node || !node.nodeName) {
|
|
2955
|
+
return void 0;
|
|
2956
|
+
}
|
|
2957
|
+
var nodeName = node.nodeName.toLowerCase();
|
|
2958
|
+
if (nodeName === "input" && node.type !== "image") {
|
|
2959
|
+
return void 0;
|
|
2960
|
+
}
|
|
2961
|
+
return URI.domAttributes[nodeName];
|
|
2962
|
+
};
|
|
2963
|
+
function escapeForDumbFirefox36(value) {
|
|
2964
|
+
return escape(value);
|
|
2965
|
+
}
|
|
2966
|
+
function strictEncodeURIComponent(string) {
|
|
2967
|
+
return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, "%2A");
|
|
2968
|
+
}
|
|
2969
|
+
URI.encode = strictEncodeURIComponent;
|
|
2970
|
+
URI.decode = decodeURIComponent;
|
|
2971
|
+
URI.iso8859 = function() {
|
|
2972
|
+
URI.encode = escape;
|
|
2973
|
+
URI.decode = unescape;
|
|
2974
|
+
};
|
|
2975
|
+
URI.unicode = function() {
|
|
2976
|
+
URI.encode = strictEncodeURIComponent;
|
|
2977
|
+
URI.decode = decodeURIComponent;
|
|
2978
|
+
};
|
|
2979
|
+
URI.characters = {
|
|
2980
|
+
pathname: {
|
|
2981
|
+
encode: {
|
|
2982
|
+
// RFC3986 2.1: For consistency, URI producers and normalizers should
|
|
2983
|
+
// use uppercase hexadecimal digits for all percent-encodings.
|
|
2984
|
+
expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
|
|
2985
|
+
map: {
|
|
2986
|
+
// -._~!'()*
|
|
2987
|
+
"%24": "$",
|
|
2988
|
+
"%26": "&",
|
|
2989
|
+
"%2B": "+",
|
|
2990
|
+
"%2C": ",",
|
|
2991
|
+
"%3B": ";",
|
|
2992
|
+
"%3D": "=",
|
|
2993
|
+
"%3A": ":",
|
|
2994
|
+
"%40": "@"
|
|
2995
|
+
}
|
|
2996
|
+
},
|
|
2997
|
+
decode: {
|
|
2998
|
+
expression: /[\/\?#]/g,
|
|
2999
|
+
map: {
|
|
3000
|
+
"/": "%2F",
|
|
3001
|
+
"?": "%3F",
|
|
3002
|
+
"#": "%23"
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
},
|
|
3006
|
+
reserved: {
|
|
3007
|
+
encode: {
|
|
3008
|
+
// RFC3986 2.1: For consistency, URI producers and normalizers should
|
|
3009
|
+
// use uppercase hexadecimal digits for all percent-encodings.
|
|
3010
|
+
expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
|
|
3011
|
+
map: {
|
|
3012
|
+
// gen-delims
|
|
3013
|
+
"%3A": ":",
|
|
3014
|
+
"%2F": "/",
|
|
3015
|
+
"%3F": "?",
|
|
3016
|
+
"%23": "#",
|
|
3017
|
+
"%5B": "[",
|
|
3018
|
+
"%5D": "]",
|
|
3019
|
+
"%40": "@",
|
|
3020
|
+
// sub-delims
|
|
3021
|
+
"%21": "!",
|
|
3022
|
+
"%24": "$",
|
|
3023
|
+
"%26": "&",
|
|
3024
|
+
"%27": "'",
|
|
3025
|
+
"%28": "(",
|
|
3026
|
+
"%29": ")",
|
|
3027
|
+
"%2A": "*",
|
|
3028
|
+
"%2B": "+",
|
|
3029
|
+
"%2C": ",",
|
|
3030
|
+
"%3B": ";",
|
|
3031
|
+
"%3D": "="
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
},
|
|
3035
|
+
urnpath: {
|
|
3036
|
+
// The characters under `encode` are the characters called out by RFC 2141 as being acceptable
|
|
3037
|
+
// for usage in a URN. RFC2141 also calls out "-", ".", and "_" as acceptable characters, but
|
|
3038
|
+
// these aren't encoded by encodeURIComponent, so we don't have to call them out here. Also
|
|
3039
|
+
// note that the colon character is not featured in the encoding map; this is because URI.js
|
|
3040
|
+
// gives the colons in URNs semantic meaning as the delimiters of path segements, and so it
|
|
3041
|
+
// should not appear unencoded in a segment itself.
|
|
3042
|
+
// See also the note above about RFC3986 and capitalalized hex digits.
|
|
3043
|
+
encode: {
|
|
3044
|
+
expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
|
|
3045
|
+
map: {
|
|
3046
|
+
"%21": "!",
|
|
3047
|
+
"%24": "$",
|
|
3048
|
+
"%27": "'",
|
|
3049
|
+
"%28": "(",
|
|
3050
|
+
"%29": ")",
|
|
3051
|
+
"%2A": "*",
|
|
3052
|
+
"%2B": "+",
|
|
3053
|
+
"%2C": ",",
|
|
3054
|
+
"%3B": ";",
|
|
3055
|
+
"%3D": "=",
|
|
3056
|
+
"%40": "@"
|
|
3057
|
+
}
|
|
3058
|
+
},
|
|
3059
|
+
// These characters are the characters called out by RFC2141 as "reserved" characters that
|
|
3060
|
+
// should never appear in a URN, plus the colon character (see note above).
|
|
3061
|
+
decode: {
|
|
3062
|
+
expression: /[\/\?#:]/g,
|
|
3063
|
+
map: {
|
|
3064
|
+
"/": "%2F",
|
|
3065
|
+
"?": "%3F",
|
|
3066
|
+
"#": "%23",
|
|
3067
|
+
":": "%3A"
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
URI.encodeQuery = function(string, escapeQuerySpace) {
|
|
3073
|
+
var escaped = URI.encode(string + "");
|
|
3074
|
+
if (escapeQuerySpace === void 0) {
|
|
3075
|
+
escapeQuerySpace = URI.escapeQuerySpace;
|
|
3076
|
+
}
|
|
3077
|
+
return escapeQuerySpace ? escaped.replace(/%20/g, "+") : escaped;
|
|
3078
|
+
};
|
|
3079
|
+
URI.decodeQuery = function(string, escapeQuerySpace) {
|
|
3080
|
+
string += "";
|
|
3081
|
+
if (escapeQuerySpace === void 0) {
|
|
3082
|
+
escapeQuerySpace = URI.escapeQuerySpace;
|
|
3083
|
+
}
|
|
3084
|
+
try {
|
|
3085
|
+
return URI.decode(escapeQuerySpace ? string.replace(/\+/g, "%20") : string);
|
|
3086
|
+
} catch (e) {
|
|
3087
|
+
return string;
|
|
3088
|
+
}
|
|
3089
|
+
};
|
|
3090
|
+
var _parts = { "encode": "encode", "decode": "decode" };
|
|
3091
|
+
var _part;
|
|
3092
|
+
var generateAccessor = function(_group, _part2) {
|
|
3093
|
+
return function(string) {
|
|
3094
|
+
try {
|
|
3095
|
+
return URI[_part2](string + "").replace(URI.characters[_group][_part2].expression, function(c) {
|
|
3096
|
+
return URI.characters[_group][_part2].map[c];
|
|
3097
|
+
});
|
|
3098
|
+
} catch (e) {
|
|
3099
|
+
return string;
|
|
3100
|
+
}
|
|
3101
|
+
};
|
|
3102
|
+
};
|
|
3103
|
+
for (_part in _parts) {
|
|
3104
|
+
URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]);
|
|
3105
|
+
URI[_part + "UrnPathSegment"] = generateAccessor("urnpath", _parts[_part]);
|
|
3106
|
+
}
|
|
3107
|
+
var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) {
|
|
3108
|
+
return function(string) {
|
|
3109
|
+
var actualCodingFunc;
|
|
3110
|
+
if (!_innerCodingFuncName) {
|
|
3111
|
+
actualCodingFunc = URI[_codingFuncName];
|
|
3112
|
+
} else {
|
|
3113
|
+
actualCodingFunc = function(string2) {
|
|
3114
|
+
return URI[_codingFuncName](URI[_innerCodingFuncName](string2));
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
var segments = (string + "").split(_sep);
|
|
3118
|
+
for (var i = 0, length = segments.length; i < length; i++) {
|
|
3119
|
+
segments[i] = actualCodingFunc(segments[i]);
|
|
3120
|
+
}
|
|
3121
|
+
return segments.join(_sep);
|
|
3122
|
+
};
|
|
3123
|
+
};
|
|
3124
|
+
URI.decodePath = generateSegmentedPathFunction("/", "decodePathSegment");
|
|
3125
|
+
URI.decodeUrnPath = generateSegmentedPathFunction(":", "decodeUrnPathSegment");
|
|
3126
|
+
URI.recodePath = generateSegmentedPathFunction("/", "encodePathSegment", "decode");
|
|
3127
|
+
URI.recodeUrnPath = generateSegmentedPathFunction(":", "encodeUrnPathSegment", "decode");
|
|
3128
|
+
URI.encodeReserved = generateAccessor("reserved", "encode");
|
|
3129
|
+
URI.parse = function(string, parts) {
|
|
3130
|
+
var pos;
|
|
3131
|
+
if (!parts) {
|
|
3132
|
+
parts = {
|
|
3133
|
+
preventInvalidHostname: URI.preventInvalidHostname
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
string = string.replace(URI.leading_whitespace_expression, "");
|
|
3137
|
+
string = string.replace(URI.ascii_tab_whitespace, "");
|
|
3138
|
+
pos = string.indexOf("#");
|
|
3139
|
+
if (pos > -1) {
|
|
3140
|
+
parts.fragment = string.substring(pos + 1) || null;
|
|
3141
|
+
string = string.substring(0, pos);
|
|
3142
|
+
}
|
|
3143
|
+
pos = string.indexOf("?");
|
|
3144
|
+
if (pos > -1) {
|
|
3145
|
+
parts.query = string.substring(pos + 1) || null;
|
|
3146
|
+
string = string.substring(0, pos);
|
|
3147
|
+
}
|
|
3148
|
+
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, "$1://");
|
|
3149
|
+
string = string.replace(/^[/\\]{2,}/i, "//");
|
|
3150
|
+
if (string.substring(0, 2) === "//") {
|
|
3151
|
+
parts.protocol = null;
|
|
3152
|
+
string = string.substring(2);
|
|
3153
|
+
string = URI.parseAuthority(string, parts);
|
|
3154
|
+
} else {
|
|
3155
|
+
pos = string.indexOf(":");
|
|
3156
|
+
if (pos > -1) {
|
|
3157
|
+
parts.protocol = string.substring(0, pos) || null;
|
|
3158
|
+
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
|
3159
|
+
parts.protocol = void 0;
|
|
3160
|
+
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, "/") === "//") {
|
|
3161
|
+
string = string.substring(pos + 3);
|
|
3162
|
+
string = URI.parseAuthority(string, parts);
|
|
3163
|
+
} else {
|
|
3164
|
+
string = string.substring(pos + 1);
|
|
3165
|
+
parts.urn = true;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
parts.path = string;
|
|
3170
|
+
return parts;
|
|
3171
|
+
};
|
|
3172
|
+
URI.parseHost = function(string, parts) {
|
|
3173
|
+
if (!string) {
|
|
3174
|
+
string = "";
|
|
3175
|
+
}
|
|
3176
|
+
string = string.replace(/\\/g, "/");
|
|
3177
|
+
var pos = string.indexOf("/");
|
|
3178
|
+
var bracketPos;
|
|
3179
|
+
var t;
|
|
3180
|
+
if (pos === -1) {
|
|
3181
|
+
pos = string.length;
|
|
3182
|
+
}
|
|
3183
|
+
if (string.charAt(0) === "[") {
|
|
3184
|
+
bracketPos = string.indexOf("]");
|
|
3185
|
+
parts.hostname = string.substring(1, bracketPos) || null;
|
|
3186
|
+
parts.port = string.substring(bracketPos + 2, pos) || null;
|
|
3187
|
+
if (parts.port === "/") {
|
|
3188
|
+
parts.port = null;
|
|
3189
|
+
}
|
|
3190
|
+
} else {
|
|
3191
|
+
var firstColon = string.indexOf(":");
|
|
3192
|
+
var firstSlash = string.indexOf("/");
|
|
3193
|
+
var nextColon = string.indexOf(":", firstColon + 1);
|
|
3194
|
+
if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
|
|
3195
|
+
parts.hostname = string.substring(0, pos) || null;
|
|
3196
|
+
parts.port = null;
|
|
3197
|
+
} else {
|
|
3198
|
+
t = string.substring(0, pos).split(":");
|
|
3199
|
+
parts.hostname = t[0] || null;
|
|
3200
|
+
parts.port = t[1] || null;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
if (parts.hostname && string.substring(pos).charAt(0) !== "/") {
|
|
3204
|
+
pos++;
|
|
3205
|
+
string = "/" + string;
|
|
3206
|
+
}
|
|
3207
|
+
if (parts.preventInvalidHostname) {
|
|
3208
|
+
URI.ensureValidHostname(parts.hostname, parts.protocol);
|
|
3209
|
+
}
|
|
3210
|
+
if (parts.port) {
|
|
3211
|
+
URI.ensureValidPort(parts.port);
|
|
3212
|
+
}
|
|
3213
|
+
return string.substring(pos) || "/";
|
|
3214
|
+
};
|
|
3215
|
+
URI.parseAuthority = function(string, parts) {
|
|
3216
|
+
string = URI.parseUserinfo(string, parts);
|
|
3217
|
+
return URI.parseHost(string, parts);
|
|
3218
|
+
};
|
|
3219
|
+
URI.parseUserinfo = function(string, parts) {
|
|
3220
|
+
var _string = string;
|
|
3221
|
+
var firstBackSlash = string.indexOf("\\");
|
|
3222
|
+
if (firstBackSlash !== -1) {
|
|
3223
|
+
string = string.replace(/\\/g, "/");
|
|
3224
|
+
}
|
|
3225
|
+
var firstSlash = string.indexOf("/");
|
|
3226
|
+
var pos = string.lastIndexOf("@", firstSlash > -1 ? firstSlash : string.length - 1);
|
|
3227
|
+
var t;
|
|
3228
|
+
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
|
|
3229
|
+
t = string.substring(0, pos).split(":");
|
|
3230
|
+
parts.username = t[0] ? URI.decode(t[0]) : null;
|
|
3231
|
+
t.shift();
|
|
3232
|
+
parts.password = t[0] ? URI.decode(t.join(":")) : null;
|
|
3233
|
+
string = _string.substring(pos + 1);
|
|
3234
|
+
} else {
|
|
3235
|
+
parts.username = null;
|
|
3236
|
+
parts.password = null;
|
|
3237
|
+
}
|
|
3238
|
+
return string;
|
|
3239
|
+
};
|
|
3240
|
+
URI.parseQuery = function(string, escapeQuerySpace) {
|
|
3241
|
+
if (!string) {
|
|
3242
|
+
return {};
|
|
3243
|
+
}
|
|
3244
|
+
string = string.replace(/&+/g, "&").replace(/^\?*&*|&+$/g, "");
|
|
3245
|
+
if (!string) {
|
|
3246
|
+
return {};
|
|
3247
|
+
}
|
|
3248
|
+
var items = {};
|
|
3249
|
+
var splits = string.split("&");
|
|
3250
|
+
var length = splits.length;
|
|
3251
|
+
var v, name, value;
|
|
3252
|
+
for (var i = 0; i < length; i++) {
|
|
3253
|
+
v = splits[i].split("=");
|
|
3254
|
+
name = URI.decodeQuery(v.shift(), escapeQuerySpace);
|
|
3255
|
+
value = v.length ? URI.decodeQuery(v.join("="), escapeQuerySpace) : null;
|
|
3256
|
+
if (name === "__proto__") {
|
|
3257
|
+
continue;
|
|
3258
|
+
} else if (hasOwn.call(items, name)) {
|
|
3259
|
+
if (typeof items[name] === "string" || items[name] === null) {
|
|
3260
|
+
items[name] = [items[name]];
|
|
3261
|
+
}
|
|
3262
|
+
items[name].push(value);
|
|
3263
|
+
} else {
|
|
3264
|
+
items[name] = value;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
return items;
|
|
3268
|
+
};
|
|
3269
|
+
URI.build = function(parts) {
|
|
3270
|
+
var t = "";
|
|
3271
|
+
var requireAbsolutePath = false;
|
|
3272
|
+
if (parts.protocol) {
|
|
3273
|
+
t += parts.protocol + ":";
|
|
3274
|
+
}
|
|
3275
|
+
if (!parts.urn && (t || parts.hostname)) {
|
|
3276
|
+
t += "//";
|
|
3277
|
+
requireAbsolutePath = true;
|
|
3278
|
+
}
|
|
3279
|
+
t += URI.buildAuthority(parts) || "";
|
|
3280
|
+
if (typeof parts.path === "string") {
|
|
3281
|
+
if (parts.path.charAt(0) !== "/" && requireAbsolutePath) {
|
|
3282
|
+
t += "/";
|
|
3283
|
+
}
|
|
3284
|
+
t += parts.path;
|
|
3285
|
+
}
|
|
3286
|
+
if (typeof parts.query === "string" && parts.query) {
|
|
3287
|
+
t += "?" + parts.query;
|
|
3288
|
+
}
|
|
3289
|
+
if (typeof parts.fragment === "string" && parts.fragment) {
|
|
3290
|
+
t += "#" + parts.fragment;
|
|
3291
|
+
}
|
|
3292
|
+
return t;
|
|
3293
|
+
};
|
|
3294
|
+
URI.buildHost = function(parts) {
|
|
3295
|
+
var t = "";
|
|
3296
|
+
if (!parts.hostname) {
|
|
3297
|
+
return "";
|
|
3298
|
+
} else if (URI.ip6_expression.test(parts.hostname)) {
|
|
3299
|
+
t += "[" + parts.hostname + "]";
|
|
3300
|
+
} else {
|
|
3301
|
+
t += parts.hostname;
|
|
3302
|
+
}
|
|
3303
|
+
if (parts.port) {
|
|
3304
|
+
t += ":" + parts.port;
|
|
3305
|
+
}
|
|
3306
|
+
return t;
|
|
3307
|
+
};
|
|
3308
|
+
URI.buildAuthority = function(parts) {
|
|
3309
|
+
return URI.buildUserinfo(parts) + URI.buildHost(parts);
|
|
3310
|
+
};
|
|
3311
|
+
URI.buildUserinfo = function(parts) {
|
|
3312
|
+
var t = "";
|
|
3313
|
+
if (parts.username) {
|
|
3314
|
+
t += URI.encode(parts.username);
|
|
3315
|
+
}
|
|
3316
|
+
if (parts.password) {
|
|
3317
|
+
t += ":" + URI.encode(parts.password);
|
|
3318
|
+
}
|
|
3319
|
+
if (t) {
|
|
3320
|
+
t += "@";
|
|
3321
|
+
}
|
|
3322
|
+
return t;
|
|
3323
|
+
};
|
|
3324
|
+
URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) {
|
|
3325
|
+
var t = "";
|
|
3326
|
+
var unique, key, i, length;
|
|
3327
|
+
for (key in data) {
|
|
3328
|
+
if (key === "__proto__") {
|
|
3329
|
+
continue;
|
|
3330
|
+
} else if (hasOwn.call(data, key)) {
|
|
3331
|
+
if (isArray(data[key])) {
|
|
3332
|
+
unique = {};
|
|
3333
|
+
for (i = 0, length = data[key].length; i < length; i++) {
|
|
3334
|
+
if (data[key][i] !== void 0 && unique[data[key][i] + ""] === void 0) {
|
|
3335
|
+
t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
|
|
3336
|
+
if (duplicateQueryParameters !== true) {
|
|
3337
|
+
unique[data[key][i] + ""] = true;
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
} else if (data[key] !== void 0) {
|
|
3342
|
+
t += "&" + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
return t.substring(1);
|
|
3347
|
+
};
|
|
3348
|
+
URI.buildQueryParameter = function(name, value, escapeQuerySpace) {
|
|
3349
|
+
return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : "");
|
|
3350
|
+
};
|
|
3351
|
+
URI.addQuery = function(data, name, value) {
|
|
3352
|
+
if (typeof name === "object") {
|
|
3353
|
+
for (var key in name) {
|
|
3354
|
+
if (hasOwn.call(name, key)) {
|
|
3355
|
+
URI.addQuery(data, key, name[key]);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
} else if (typeof name === "string") {
|
|
3359
|
+
if (data[name] === void 0) {
|
|
3360
|
+
data[name] = value;
|
|
3361
|
+
return;
|
|
3362
|
+
} else if (typeof data[name] === "string") {
|
|
3363
|
+
data[name] = [data[name]];
|
|
3364
|
+
}
|
|
3365
|
+
if (!isArray(value)) {
|
|
3366
|
+
value = [value];
|
|
3367
|
+
}
|
|
3368
|
+
data[name] = (data[name] || []).concat(value);
|
|
3369
|
+
} else {
|
|
3370
|
+
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
URI.setQuery = function(data, name, value) {
|
|
3374
|
+
if (typeof name === "object") {
|
|
3375
|
+
for (var key in name) {
|
|
3376
|
+
if (hasOwn.call(name, key)) {
|
|
3377
|
+
URI.setQuery(data, key, name[key]);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
} else if (typeof name === "string") {
|
|
3381
|
+
data[name] = value === void 0 ? null : value;
|
|
3382
|
+
} else {
|
|
3383
|
+
throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
URI.removeQuery = function(data, name, value) {
|
|
3387
|
+
var i, length, key;
|
|
3388
|
+
if (isArray(name)) {
|
|
3389
|
+
for (i = 0, length = name.length; i < length; i++) {
|
|
3390
|
+
data[name[i]] = void 0;
|
|
3391
|
+
}
|
|
3392
|
+
} else if (getType(name) === "RegExp") {
|
|
3393
|
+
for (key in data) {
|
|
3394
|
+
if (name.test(key)) {
|
|
3395
|
+
data[key] = void 0;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
} else if (typeof name === "object") {
|
|
3399
|
+
for (key in name) {
|
|
3400
|
+
if (hasOwn.call(name, key)) {
|
|
3401
|
+
URI.removeQuery(data, key, name[key]);
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
} else if (typeof name === "string") {
|
|
3405
|
+
if (value !== void 0) {
|
|
3406
|
+
if (getType(value) === "RegExp") {
|
|
3407
|
+
if (!isArray(data[name]) && value.test(data[name])) {
|
|
3408
|
+
data[name] = void 0;
|
|
3409
|
+
} else {
|
|
3410
|
+
data[name] = filterArrayValues(data[name], value);
|
|
3411
|
+
}
|
|
3412
|
+
} else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
|
|
3413
|
+
data[name] = void 0;
|
|
3414
|
+
} else if (isArray(data[name])) {
|
|
3415
|
+
data[name] = filterArrayValues(data[name], value);
|
|
3416
|
+
}
|
|
3417
|
+
} else {
|
|
3418
|
+
data[name] = void 0;
|
|
3419
|
+
}
|
|
3420
|
+
} else {
|
|
3421
|
+
throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");
|
|
3422
|
+
}
|
|
3423
|
+
};
|
|
3424
|
+
URI.hasQuery = function(data, name, value, withinArray) {
|
|
3425
|
+
switch (getType(name)) {
|
|
3426
|
+
case "String":
|
|
3427
|
+
break;
|
|
3428
|
+
case "RegExp":
|
|
3429
|
+
for (var key in data) {
|
|
3430
|
+
if (hasOwn.call(data, key)) {
|
|
3431
|
+
if (name.test(key) && (value === void 0 || URI.hasQuery(data, key, value))) {
|
|
3432
|
+
return true;
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
return false;
|
|
3437
|
+
case "Object":
|
|
3438
|
+
for (var _key in name) {
|
|
3439
|
+
if (hasOwn.call(name, _key)) {
|
|
3440
|
+
if (!URI.hasQuery(data, _key, name[_key])) {
|
|
3441
|
+
return false;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
return true;
|
|
3446
|
+
default:
|
|
3447
|
+
throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");
|
|
3448
|
+
}
|
|
3449
|
+
switch (getType(value)) {
|
|
3450
|
+
case "Undefined":
|
|
3451
|
+
return name in data;
|
|
3452
|
+
case "Boolean":
|
|
3453
|
+
var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
|
|
3454
|
+
return value === _booly;
|
|
3455
|
+
case "Function":
|
|
3456
|
+
return !!value(data[name], name, data);
|
|
3457
|
+
case "Array":
|
|
3458
|
+
if (!isArray(data[name])) {
|
|
3459
|
+
return false;
|
|
3460
|
+
}
|
|
3461
|
+
var op = withinArray ? arrayContains : arraysEqual;
|
|
3462
|
+
return op(data[name], value);
|
|
3463
|
+
case "RegExp":
|
|
3464
|
+
if (!isArray(data[name])) {
|
|
3465
|
+
return Boolean(data[name] && data[name].match(value));
|
|
3466
|
+
}
|
|
3467
|
+
if (!withinArray) {
|
|
3468
|
+
return false;
|
|
3469
|
+
}
|
|
3470
|
+
return arrayContains(data[name], value);
|
|
3471
|
+
case "Number":
|
|
3472
|
+
value = String(value);
|
|
3473
|
+
case "String":
|
|
3474
|
+
if (!isArray(data[name])) {
|
|
3475
|
+
return data[name] === value;
|
|
3476
|
+
}
|
|
3477
|
+
if (!withinArray) {
|
|
3478
|
+
return false;
|
|
3479
|
+
}
|
|
3480
|
+
return arrayContains(data[name], value);
|
|
3481
|
+
default:
|
|
3482
|
+
throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
URI.joinPaths = function() {
|
|
3486
|
+
var input = [];
|
|
3487
|
+
var segments = [];
|
|
3488
|
+
var nonEmptySegments = 0;
|
|
3489
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
3490
|
+
var url = new URI(arguments[i]);
|
|
3491
|
+
input.push(url);
|
|
3492
|
+
var _segments = url.segment();
|
|
3493
|
+
for (var s = 0; s < _segments.length; s++) {
|
|
3494
|
+
if (typeof _segments[s] === "string") {
|
|
3495
|
+
segments.push(_segments[s]);
|
|
3496
|
+
}
|
|
3497
|
+
if (_segments[s]) {
|
|
3498
|
+
nonEmptySegments++;
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
if (!segments.length || !nonEmptySegments) {
|
|
3503
|
+
return new URI("");
|
|
3504
|
+
}
|
|
3505
|
+
var uri = new URI("").segment(segments);
|
|
3506
|
+
if (input[0].path() === "" || input[0].path().slice(0, 1) === "/") {
|
|
3507
|
+
uri.path("/" + uri.path());
|
|
3508
|
+
}
|
|
3509
|
+
return uri.normalize();
|
|
3510
|
+
};
|
|
3511
|
+
URI.commonPath = function(one, two) {
|
|
3512
|
+
var length = Math.min(one.length, two.length);
|
|
3513
|
+
var pos;
|
|
3514
|
+
for (pos = 0; pos < length; pos++) {
|
|
3515
|
+
if (one.charAt(pos) !== two.charAt(pos)) {
|
|
3516
|
+
pos--;
|
|
3517
|
+
break;
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
if (pos < 1) {
|
|
3521
|
+
return one.charAt(0) === two.charAt(0) && one.charAt(0) === "/" ? "/" : "";
|
|
3522
|
+
}
|
|
3523
|
+
if (one.charAt(pos) !== "/" || two.charAt(pos) !== "/") {
|
|
3524
|
+
pos = one.substring(0, pos).lastIndexOf("/");
|
|
3525
|
+
}
|
|
3526
|
+
return one.substring(0, pos + 1);
|
|
3527
|
+
};
|
|
3528
|
+
URI.withinString = function(string, callback, options) {
|
|
3529
|
+
options || (options = {});
|
|
3530
|
+
var _start = options.start || URI.findUri.start;
|
|
3531
|
+
var _end = options.end || URI.findUri.end;
|
|
3532
|
+
var _trim = options.trim || URI.findUri.trim;
|
|
3533
|
+
var _parens = options.parens || URI.findUri.parens;
|
|
3534
|
+
var _attributeOpen = /[a-z0-9-]=["']?$/i;
|
|
3535
|
+
_start.lastIndex = 0;
|
|
3536
|
+
while (true) {
|
|
3537
|
+
var match = _start.exec(string);
|
|
3538
|
+
if (!match) {
|
|
3539
|
+
break;
|
|
3540
|
+
}
|
|
3541
|
+
var start = match.index;
|
|
3542
|
+
if (options.ignoreHtml) {
|
|
3543
|
+
var attributeOpen = string.slice(Math.max(start - 3, 0), start);
|
|
3544
|
+
if (attributeOpen && _attributeOpen.test(attributeOpen)) {
|
|
3545
|
+
continue;
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
var end = start + string.slice(start).search(_end);
|
|
3549
|
+
var slice = string.slice(start, end);
|
|
3550
|
+
var parensEnd = -1;
|
|
3551
|
+
while (true) {
|
|
3552
|
+
var parensMatch = _parens.exec(slice);
|
|
3553
|
+
if (!parensMatch) {
|
|
3554
|
+
break;
|
|
3555
|
+
}
|
|
3556
|
+
var parensMatchEnd = parensMatch.index + parensMatch[0].length;
|
|
3557
|
+
parensEnd = Math.max(parensEnd, parensMatchEnd);
|
|
3558
|
+
}
|
|
3559
|
+
if (parensEnd > -1) {
|
|
3560
|
+
slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, "");
|
|
3561
|
+
} else {
|
|
3562
|
+
slice = slice.replace(_trim, "");
|
|
3563
|
+
}
|
|
3564
|
+
if (slice.length <= match[0].length) {
|
|
3565
|
+
continue;
|
|
3566
|
+
}
|
|
3567
|
+
if (options.ignore && options.ignore.test(slice)) {
|
|
3568
|
+
continue;
|
|
3569
|
+
}
|
|
3570
|
+
end = start + slice.length;
|
|
3571
|
+
var result = callback(slice, start, end, string);
|
|
3572
|
+
if (result === void 0) {
|
|
3573
|
+
_start.lastIndex = end;
|
|
3574
|
+
continue;
|
|
3575
|
+
}
|
|
3576
|
+
result = String(result);
|
|
3577
|
+
string = string.slice(0, start) + result + string.slice(end);
|
|
3578
|
+
_start.lastIndex = start + result.length;
|
|
3579
|
+
}
|
|
3580
|
+
_start.lastIndex = 0;
|
|
3581
|
+
return string;
|
|
3582
|
+
};
|
|
3583
|
+
URI.ensureValidHostname = function(v, protocol) {
|
|
3584
|
+
var hasHostname = !!v;
|
|
3585
|
+
var hasProtocol = !!protocol;
|
|
3586
|
+
var rejectEmptyHostname = false;
|
|
3587
|
+
if (hasProtocol) {
|
|
3588
|
+
rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
|
|
3589
|
+
}
|
|
3590
|
+
if (rejectEmptyHostname && !hasHostname) {
|
|
3591
|
+
throw new TypeError("Hostname cannot be empty, if protocol is " + protocol);
|
|
3592
|
+
} else if (v && v.match(URI.invalid_hostname_characters)) {
|
|
3593
|
+
if (!punycode) {
|
|
3594
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');
|
|
3595
|
+
}
|
|
3596
|
+
if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
|
|
3597
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_]');
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
URI.ensureValidPort = function(v) {
|
|
3602
|
+
if (!v) {
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
var port = Number(v);
|
|
3606
|
+
if (isInteger(port) && port > 0 && port < 65536) {
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
throw new TypeError('Port "' + v + '" is not a valid port');
|
|
3610
|
+
};
|
|
3611
|
+
URI.noConflict = function(removeAll) {
|
|
3612
|
+
if (removeAll) {
|
|
3613
|
+
var unconflicted = {
|
|
3614
|
+
URI: this.noConflict()
|
|
3615
|
+
};
|
|
3616
|
+
if (root.URITemplate && typeof root.URITemplate.noConflict === "function") {
|
|
3617
|
+
unconflicted.URITemplate = root.URITemplate.noConflict();
|
|
3618
|
+
}
|
|
3619
|
+
if (root.IPv6 && typeof root.IPv6.noConflict === "function") {
|
|
3620
|
+
unconflicted.IPv6 = root.IPv6.noConflict();
|
|
3621
|
+
}
|
|
3622
|
+
if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === "function") {
|
|
3623
|
+
unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict();
|
|
3624
|
+
}
|
|
3625
|
+
return unconflicted;
|
|
3626
|
+
} else if (root.URI === this) {
|
|
3627
|
+
root.URI = _URI;
|
|
3628
|
+
}
|
|
3629
|
+
return this;
|
|
3630
|
+
};
|
|
3631
|
+
p.build = function(deferBuild) {
|
|
3632
|
+
if (deferBuild === true) {
|
|
3633
|
+
this._deferred_build = true;
|
|
3634
|
+
} else if (deferBuild === void 0 || this._deferred_build) {
|
|
3635
|
+
this._string = URI.build(this._parts);
|
|
3636
|
+
this._deferred_build = false;
|
|
3637
|
+
}
|
|
3638
|
+
return this;
|
|
3639
|
+
};
|
|
3640
|
+
p.clone = function() {
|
|
3641
|
+
return new URI(this);
|
|
3642
|
+
};
|
|
3643
|
+
p.valueOf = p.toString = function() {
|
|
3644
|
+
return this.build(false)._string;
|
|
3645
|
+
};
|
|
3646
|
+
function generateSimpleAccessor(_part2) {
|
|
3647
|
+
return function(v, build) {
|
|
3648
|
+
if (v === void 0) {
|
|
3649
|
+
return this._parts[_part2] || "";
|
|
3650
|
+
} else {
|
|
3651
|
+
this._parts[_part2] = v || null;
|
|
3652
|
+
this.build(!build);
|
|
3653
|
+
return this;
|
|
3654
|
+
}
|
|
3655
|
+
};
|
|
3656
|
+
}
|
|
3657
|
+
function generatePrefixAccessor(_part2, _key) {
|
|
3658
|
+
return function(v, build) {
|
|
3659
|
+
if (v === void 0) {
|
|
3660
|
+
return this._parts[_part2] || "";
|
|
3661
|
+
} else {
|
|
3662
|
+
if (v !== null) {
|
|
3663
|
+
v = v + "";
|
|
3664
|
+
if (v.charAt(0) === _key) {
|
|
3665
|
+
v = v.substring(1);
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
this._parts[_part2] = v;
|
|
3669
|
+
this.build(!build);
|
|
3670
|
+
return this;
|
|
3671
|
+
}
|
|
3672
|
+
};
|
|
3673
|
+
}
|
|
3674
|
+
p.protocol = generateSimpleAccessor("protocol");
|
|
3675
|
+
p.username = generateSimpleAccessor("username");
|
|
3676
|
+
p.password = generateSimpleAccessor("password");
|
|
3677
|
+
p.hostname = generateSimpleAccessor("hostname");
|
|
3678
|
+
p.port = generateSimpleAccessor("port");
|
|
3679
|
+
p.query = generatePrefixAccessor("query", "?");
|
|
3680
|
+
p.fragment = generatePrefixAccessor("fragment", "#");
|
|
3681
|
+
p.search = function(v, build) {
|
|
3682
|
+
var t = this.query(v, build);
|
|
3683
|
+
return typeof t === "string" && t.length ? "?" + t : t;
|
|
3684
|
+
};
|
|
3685
|
+
p.hash = function(v, build) {
|
|
3686
|
+
var t = this.fragment(v, build);
|
|
3687
|
+
return typeof t === "string" && t.length ? "#" + t : t;
|
|
3688
|
+
};
|
|
3689
|
+
p.pathname = function(v, build) {
|
|
3690
|
+
if (v === void 0 || v === true) {
|
|
3691
|
+
var res = this._parts.path || (this._parts.hostname ? "/" : "");
|
|
3692
|
+
return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
|
|
3693
|
+
} else {
|
|
3694
|
+
if (this._parts.urn) {
|
|
3695
|
+
this._parts.path = v ? URI.recodeUrnPath(v) : "";
|
|
3696
|
+
} else {
|
|
3697
|
+
this._parts.path = v ? URI.recodePath(v) : "/";
|
|
3698
|
+
}
|
|
3699
|
+
this.build(!build);
|
|
3700
|
+
return this;
|
|
3701
|
+
}
|
|
3702
|
+
};
|
|
3703
|
+
p.path = p.pathname;
|
|
3704
|
+
p.href = function(href, build) {
|
|
3705
|
+
var key;
|
|
3706
|
+
if (href === void 0) {
|
|
3707
|
+
return this.toString();
|
|
3708
|
+
}
|
|
3709
|
+
this._string = "";
|
|
3710
|
+
this._parts = URI._parts();
|
|
3711
|
+
var _URI2 = href instanceof URI;
|
|
3712
|
+
var _object = typeof href === "object" && (href.hostname || href.path || href.pathname);
|
|
3713
|
+
if (href.nodeName) {
|
|
3714
|
+
var attribute = URI.getDomAttribute(href);
|
|
3715
|
+
href = href[attribute] || "";
|
|
3716
|
+
_object = false;
|
|
3717
|
+
}
|
|
3718
|
+
if (!_URI2 && _object && href.pathname !== void 0) {
|
|
3719
|
+
href = href.toString();
|
|
3720
|
+
}
|
|
3721
|
+
if (typeof href === "string" || href instanceof String) {
|
|
3722
|
+
this._parts = URI.parse(String(href), this._parts);
|
|
3723
|
+
} else if (_URI2 || _object) {
|
|
3724
|
+
var src = _URI2 ? href._parts : href;
|
|
3725
|
+
for (key in src) {
|
|
3726
|
+
if (key === "query") {
|
|
3727
|
+
continue;
|
|
3728
|
+
}
|
|
3729
|
+
if (hasOwn.call(this._parts, key)) {
|
|
3730
|
+
this._parts[key] = src[key];
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
if (src.query) {
|
|
3734
|
+
this.query(src.query, false);
|
|
3735
|
+
}
|
|
3736
|
+
} else {
|
|
3737
|
+
throw new TypeError("invalid input");
|
|
3738
|
+
}
|
|
3739
|
+
this.build(!build);
|
|
3740
|
+
return this;
|
|
3741
|
+
};
|
|
3742
|
+
p.is = function(what) {
|
|
3743
|
+
var ip = false;
|
|
3744
|
+
var ip4 = false;
|
|
3745
|
+
var ip6 = false;
|
|
3746
|
+
var name = false;
|
|
3747
|
+
var sld = false;
|
|
3748
|
+
var idn = false;
|
|
3749
|
+
var punycode2 = false;
|
|
3750
|
+
var relative = !this._parts.urn;
|
|
3751
|
+
if (this._parts.hostname) {
|
|
3752
|
+
relative = false;
|
|
3753
|
+
ip4 = URI.ip4_expression.test(this._parts.hostname);
|
|
3754
|
+
ip6 = URI.ip6_expression.test(this._parts.hostname);
|
|
3755
|
+
ip = ip4 || ip6;
|
|
3756
|
+
name = !ip;
|
|
3757
|
+
sld = name && SLD && SLD.has(this._parts.hostname);
|
|
3758
|
+
idn = name && URI.idn_expression.test(this._parts.hostname);
|
|
3759
|
+
punycode2 = name && URI.punycode_expression.test(this._parts.hostname);
|
|
3760
|
+
}
|
|
3761
|
+
switch (what.toLowerCase()) {
|
|
3762
|
+
case "relative":
|
|
3763
|
+
return relative;
|
|
3764
|
+
case "absolute":
|
|
3765
|
+
return !relative;
|
|
3766
|
+
case "domain":
|
|
3767
|
+
case "name":
|
|
3768
|
+
return name;
|
|
3769
|
+
case "sld":
|
|
3770
|
+
return sld;
|
|
3771
|
+
case "ip":
|
|
3772
|
+
return ip;
|
|
3773
|
+
case "ip4":
|
|
3774
|
+
case "ipv4":
|
|
3775
|
+
case "inet4":
|
|
3776
|
+
return ip4;
|
|
3777
|
+
case "ip6":
|
|
3778
|
+
case "ipv6":
|
|
3779
|
+
case "inet6":
|
|
3780
|
+
return ip6;
|
|
3781
|
+
case "idn":
|
|
3782
|
+
return idn;
|
|
3783
|
+
case "url":
|
|
3784
|
+
return !this._parts.urn;
|
|
3785
|
+
case "urn":
|
|
3786
|
+
return !!this._parts.urn;
|
|
3787
|
+
case "punycode":
|
|
3788
|
+
return punycode2;
|
|
3789
|
+
}
|
|
3790
|
+
return null;
|
|
3791
|
+
};
|
|
3792
|
+
var _protocol = p.protocol;
|
|
3793
|
+
var _port = p.port;
|
|
3794
|
+
var _hostname = p.hostname;
|
|
3795
|
+
p.protocol = function(v, build) {
|
|
3796
|
+
if (v) {
|
|
3797
|
+
v = v.replace(/:(\/\/)?$/, "");
|
|
3798
|
+
if (!v.match(URI.protocol_expression)) {
|
|
3799
|
+
throw new TypeError('Protocol "' + v + `" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]`);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
return _protocol.call(this, v, build);
|
|
3803
|
+
};
|
|
3804
|
+
p.scheme = p.protocol;
|
|
3805
|
+
p.port = function(v, build) {
|
|
3806
|
+
if (this._parts.urn) {
|
|
3807
|
+
return v === void 0 ? "" : this;
|
|
3808
|
+
}
|
|
3809
|
+
if (v !== void 0) {
|
|
3810
|
+
if (v === 0) {
|
|
3811
|
+
v = null;
|
|
3812
|
+
}
|
|
3813
|
+
if (v) {
|
|
3814
|
+
v += "";
|
|
3815
|
+
if (v.charAt(0) === ":") {
|
|
3816
|
+
v = v.substring(1);
|
|
3817
|
+
}
|
|
3818
|
+
URI.ensureValidPort(v);
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
return _port.call(this, v, build);
|
|
3822
|
+
};
|
|
3823
|
+
p.hostname = function(v, build) {
|
|
3824
|
+
if (this._parts.urn) {
|
|
3825
|
+
return v === void 0 ? "" : this;
|
|
3826
|
+
}
|
|
3827
|
+
if (v !== void 0) {
|
|
3828
|
+
var x = { preventInvalidHostname: this._parts.preventInvalidHostname };
|
|
3829
|
+
var res = URI.parseHost(v, x);
|
|
3830
|
+
if (res !== "/") {
|
|
3831
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
|
3832
|
+
}
|
|
3833
|
+
v = x.hostname;
|
|
3834
|
+
if (this._parts.preventInvalidHostname) {
|
|
3835
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
return _hostname.call(this, v, build);
|
|
3839
|
+
};
|
|
3840
|
+
p.origin = function(v, build) {
|
|
3841
|
+
if (this._parts.urn) {
|
|
3842
|
+
return v === void 0 ? "" : this;
|
|
3843
|
+
}
|
|
3844
|
+
if (v === void 0) {
|
|
3845
|
+
var protocol = this.protocol();
|
|
3846
|
+
var authority = this.authority();
|
|
3847
|
+
if (!authority) {
|
|
3848
|
+
return "";
|
|
3849
|
+
}
|
|
3850
|
+
return (protocol ? protocol + "://" : "") + this.authority();
|
|
3851
|
+
} else {
|
|
3852
|
+
var origin = URI(v);
|
|
3853
|
+
this.protocol(origin.protocol()).authority(origin.authority()).build(!build);
|
|
3854
|
+
return this;
|
|
3855
|
+
}
|
|
3856
|
+
};
|
|
3857
|
+
p.host = function(v, build) {
|
|
3858
|
+
if (this._parts.urn) {
|
|
3859
|
+
return v === void 0 ? "" : this;
|
|
3860
|
+
}
|
|
3861
|
+
if (v === void 0) {
|
|
3862
|
+
return this._parts.hostname ? URI.buildHost(this._parts) : "";
|
|
3863
|
+
} else {
|
|
3864
|
+
var res = URI.parseHost(v, this._parts);
|
|
3865
|
+
if (res !== "/") {
|
|
3866
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
|
3867
|
+
}
|
|
3868
|
+
this.build(!build);
|
|
3869
|
+
return this;
|
|
3870
|
+
}
|
|
3871
|
+
};
|
|
3872
|
+
p.authority = function(v, build) {
|
|
3873
|
+
if (this._parts.urn) {
|
|
3874
|
+
return v === void 0 ? "" : this;
|
|
3875
|
+
}
|
|
3876
|
+
if (v === void 0) {
|
|
3877
|
+
return this._parts.hostname ? URI.buildAuthority(this._parts) : "";
|
|
3878
|
+
} else {
|
|
3879
|
+
var res = URI.parseAuthority(v, this._parts);
|
|
3880
|
+
if (res !== "/") {
|
|
3881
|
+
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
|
|
3882
|
+
}
|
|
3883
|
+
this.build(!build);
|
|
3884
|
+
return this;
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
p.userinfo = function(v, build) {
|
|
3888
|
+
if (this._parts.urn) {
|
|
3889
|
+
return v === void 0 ? "" : this;
|
|
3890
|
+
}
|
|
3891
|
+
if (v === void 0) {
|
|
3892
|
+
var t = URI.buildUserinfo(this._parts);
|
|
3893
|
+
return t ? t.substring(0, t.length - 1) : t;
|
|
3894
|
+
} else {
|
|
3895
|
+
if (v[v.length - 1] !== "@") {
|
|
3896
|
+
v += "@";
|
|
3897
|
+
}
|
|
3898
|
+
URI.parseUserinfo(v, this._parts);
|
|
3899
|
+
this.build(!build);
|
|
3900
|
+
return this;
|
|
3901
|
+
}
|
|
3902
|
+
};
|
|
3903
|
+
p.resource = function(v, build) {
|
|
3904
|
+
var parts;
|
|
3905
|
+
if (v === void 0) {
|
|
3906
|
+
return this.path() + this.search() + this.hash();
|
|
3907
|
+
}
|
|
3908
|
+
parts = URI.parse(v);
|
|
3909
|
+
this._parts.path = parts.path;
|
|
3910
|
+
this._parts.query = parts.query;
|
|
3911
|
+
this._parts.fragment = parts.fragment;
|
|
3912
|
+
this.build(!build);
|
|
3913
|
+
return this;
|
|
3914
|
+
};
|
|
3915
|
+
p.subdomain = function(v, build) {
|
|
3916
|
+
if (this._parts.urn) {
|
|
3917
|
+
return v === void 0 ? "" : this;
|
|
3918
|
+
}
|
|
3919
|
+
if (v === void 0) {
|
|
3920
|
+
if (!this._parts.hostname || this.is("IP")) {
|
|
3921
|
+
return "";
|
|
3922
|
+
}
|
|
3923
|
+
var end = this._parts.hostname.length - this.domain().length - 1;
|
|
3924
|
+
return this._parts.hostname.substring(0, end) || "";
|
|
3925
|
+
} else {
|
|
3926
|
+
var e = this._parts.hostname.length - this.domain().length;
|
|
3927
|
+
var sub = this._parts.hostname.substring(0, e);
|
|
3928
|
+
var replace = new RegExp("^" + escapeRegEx(sub));
|
|
3929
|
+
if (v && v.charAt(v.length - 1) !== ".") {
|
|
3930
|
+
v += ".";
|
|
3931
|
+
}
|
|
3932
|
+
if (v.indexOf(":") !== -1) {
|
|
3933
|
+
throw new TypeError("Domains cannot contain colons");
|
|
3934
|
+
}
|
|
3935
|
+
if (v) {
|
|
3936
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
|
3937
|
+
}
|
|
3938
|
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
3939
|
+
this.build(!build);
|
|
3940
|
+
return this;
|
|
3941
|
+
}
|
|
3942
|
+
};
|
|
3943
|
+
p.domain = function(v, build) {
|
|
3944
|
+
if (this._parts.urn) {
|
|
3945
|
+
return v === void 0 ? "" : this;
|
|
3946
|
+
}
|
|
3947
|
+
if (typeof v === "boolean") {
|
|
3948
|
+
build = v;
|
|
3949
|
+
v = void 0;
|
|
3950
|
+
}
|
|
3951
|
+
if (v === void 0) {
|
|
3952
|
+
if (!this._parts.hostname || this.is("IP")) {
|
|
3953
|
+
return "";
|
|
3954
|
+
}
|
|
3955
|
+
var t = this._parts.hostname.match(/\./g);
|
|
3956
|
+
if (t && t.length < 2) {
|
|
3957
|
+
return this._parts.hostname;
|
|
3958
|
+
}
|
|
3959
|
+
var end = this._parts.hostname.length - this.tld(build).length - 1;
|
|
3960
|
+
end = this._parts.hostname.lastIndexOf(".", end - 1) + 1;
|
|
3961
|
+
return this._parts.hostname.substring(end) || "";
|
|
3962
|
+
} else {
|
|
3963
|
+
if (!v) {
|
|
3964
|
+
throw new TypeError("cannot set domain empty");
|
|
3965
|
+
}
|
|
3966
|
+
if (v.indexOf(":") !== -1) {
|
|
3967
|
+
throw new TypeError("Domains cannot contain colons");
|
|
3968
|
+
}
|
|
3969
|
+
URI.ensureValidHostname(v, this._parts.protocol);
|
|
3970
|
+
if (!this._parts.hostname || this.is("IP")) {
|
|
3971
|
+
this._parts.hostname = v;
|
|
3972
|
+
} else {
|
|
3973
|
+
var replace = new RegExp(escapeRegEx(this.domain()) + "$");
|
|
3974
|
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
3975
|
+
}
|
|
3976
|
+
this.build(!build);
|
|
3977
|
+
return this;
|
|
3978
|
+
}
|
|
3979
|
+
};
|
|
3980
|
+
p.tld = function(v, build) {
|
|
3981
|
+
if (this._parts.urn) {
|
|
3982
|
+
return v === void 0 ? "" : this;
|
|
3983
|
+
}
|
|
3984
|
+
if (typeof v === "boolean") {
|
|
3985
|
+
build = v;
|
|
3986
|
+
v = void 0;
|
|
3987
|
+
}
|
|
3988
|
+
if (v === void 0) {
|
|
3989
|
+
if (!this._parts.hostname || this.is("IP")) {
|
|
3990
|
+
return "";
|
|
3991
|
+
}
|
|
3992
|
+
var pos = this._parts.hostname.lastIndexOf(".");
|
|
3993
|
+
var tld = this._parts.hostname.substring(pos + 1);
|
|
3994
|
+
if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
|
|
3995
|
+
return SLD.get(this._parts.hostname) || tld;
|
|
3996
|
+
}
|
|
3997
|
+
return tld;
|
|
3998
|
+
} else {
|
|
3999
|
+
var replace;
|
|
4000
|
+
if (!v) {
|
|
4001
|
+
throw new TypeError("cannot set TLD empty");
|
|
4002
|
+
} else if (v.match(/[^a-zA-Z0-9-]/)) {
|
|
4003
|
+
if (SLD && SLD.is(v)) {
|
|
4004
|
+
replace = new RegExp(escapeRegEx(this.tld()) + "$");
|
|
4005
|
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
4006
|
+
} else {
|
|
4007
|
+
throw new TypeError('TLD "' + v + '" contains characters other than [A-Z0-9]');
|
|
4008
|
+
}
|
|
4009
|
+
} else if (!this._parts.hostname || this.is("IP")) {
|
|
4010
|
+
throw new ReferenceError("cannot set TLD on non-domain host");
|
|
4011
|
+
} else {
|
|
4012
|
+
replace = new RegExp(escapeRegEx(this.tld()) + "$");
|
|
4013
|
+
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
4014
|
+
}
|
|
4015
|
+
this.build(!build);
|
|
4016
|
+
return this;
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
p.directory = function(v, build) {
|
|
4020
|
+
if (this._parts.urn) {
|
|
4021
|
+
return v === void 0 ? "" : this;
|
|
4022
|
+
}
|
|
4023
|
+
if (v === void 0 || v === true) {
|
|
4024
|
+
if (!this._parts.path && !this._parts.hostname) {
|
|
4025
|
+
return "";
|
|
4026
|
+
}
|
|
4027
|
+
if (this._parts.path === "/") {
|
|
4028
|
+
return "/";
|
|
4029
|
+
}
|
|
4030
|
+
var end = this._parts.path.length - this.filename().length - 1;
|
|
4031
|
+
var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : "");
|
|
4032
|
+
return v ? URI.decodePath(res) : res;
|
|
4033
|
+
} else {
|
|
4034
|
+
var e = this._parts.path.length - this.filename().length;
|
|
4035
|
+
var directory = this._parts.path.substring(0, e);
|
|
4036
|
+
var replace = new RegExp("^" + escapeRegEx(directory));
|
|
4037
|
+
if (!this.is("relative")) {
|
|
4038
|
+
if (!v) {
|
|
4039
|
+
v = "/";
|
|
4040
|
+
}
|
|
4041
|
+
if (v.charAt(0) !== "/") {
|
|
4042
|
+
v = "/" + v;
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
if (v && v.charAt(v.length - 1) !== "/") {
|
|
4046
|
+
v += "/";
|
|
4047
|
+
}
|
|
4048
|
+
v = URI.recodePath(v);
|
|
4049
|
+
this._parts.path = this._parts.path.replace(replace, v);
|
|
4050
|
+
this.build(!build);
|
|
4051
|
+
return this;
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
p.filename = function(v, build) {
|
|
4055
|
+
if (this._parts.urn) {
|
|
4056
|
+
return v === void 0 ? "" : this;
|
|
4057
|
+
}
|
|
4058
|
+
if (typeof v !== "string") {
|
|
4059
|
+
if (!this._parts.path || this._parts.path === "/") {
|
|
4060
|
+
return "";
|
|
4061
|
+
}
|
|
4062
|
+
var pos = this._parts.path.lastIndexOf("/");
|
|
4063
|
+
var res = this._parts.path.substring(pos + 1);
|
|
4064
|
+
return v ? URI.decodePathSegment(res) : res;
|
|
4065
|
+
} else {
|
|
4066
|
+
var mutatedDirectory = false;
|
|
4067
|
+
if (v.charAt(0) === "/") {
|
|
4068
|
+
v = v.substring(1);
|
|
4069
|
+
}
|
|
4070
|
+
if (v.match(/\.?\//)) {
|
|
4071
|
+
mutatedDirectory = true;
|
|
4072
|
+
}
|
|
4073
|
+
var replace = new RegExp(escapeRegEx(this.filename()) + "$");
|
|
4074
|
+
v = URI.recodePath(v);
|
|
4075
|
+
this._parts.path = this._parts.path.replace(replace, v);
|
|
4076
|
+
if (mutatedDirectory) {
|
|
4077
|
+
this.normalizePath(build);
|
|
4078
|
+
} else {
|
|
4079
|
+
this.build(!build);
|
|
4080
|
+
}
|
|
4081
|
+
return this;
|
|
4082
|
+
}
|
|
4083
|
+
};
|
|
4084
|
+
p.suffix = function(v, build) {
|
|
4085
|
+
if (this._parts.urn) {
|
|
4086
|
+
return v === void 0 ? "" : this;
|
|
4087
|
+
}
|
|
4088
|
+
if (v === void 0 || v === true) {
|
|
4089
|
+
if (!this._parts.path || this._parts.path === "/") {
|
|
4090
|
+
return "";
|
|
4091
|
+
}
|
|
4092
|
+
var filename = this.filename();
|
|
4093
|
+
var pos = filename.lastIndexOf(".");
|
|
4094
|
+
var s, res;
|
|
4095
|
+
if (pos === -1) {
|
|
4096
|
+
return "";
|
|
4097
|
+
}
|
|
4098
|
+
s = filename.substring(pos + 1);
|
|
4099
|
+
res = /^[a-z0-9%]+$/i.test(s) ? s : "";
|
|
4100
|
+
return v ? URI.decodePathSegment(res) : res;
|
|
4101
|
+
} else {
|
|
4102
|
+
if (v.charAt(0) === ".") {
|
|
4103
|
+
v = v.substring(1);
|
|
4104
|
+
}
|
|
4105
|
+
var suffix = this.suffix();
|
|
4106
|
+
var replace;
|
|
4107
|
+
if (!suffix) {
|
|
4108
|
+
if (!v) {
|
|
4109
|
+
return this;
|
|
4110
|
+
}
|
|
4111
|
+
this._parts.path += "." + URI.recodePath(v);
|
|
4112
|
+
} else if (!v) {
|
|
4113
|
+
replace = new RegExp(escapeRegEx("." + suffix) + "$");
|
|
4114
|
+
} else {
|
|
4115
|
+
replace = new RegExp(escapeRegEx(suffix) + "$");
|
|
4116
|
+
}
|
|
4117
|
+
if (replace) {
|
|
4118
|
+
v = URI.recodePath(v);
|
|
4119
|
+
this._parts.path = this._parts.path.replace(replace, v);
|
|
4120
|
+
}
|
|
4121
|
+
this.build(!build);
|
|
4122
|
+
return this;
|
|
4123
|
+
}
|
|
4124
|
+
};
|
|
4125
|
+
p.segment = function(segment, v, build) {
|
|
4126
|
+
var separator = this._parts.urn ? ":" : "/";
|
|
4127
|
+
var path = this.path();
|
|
4128
|
+
var absolute = path.substring(0, 1) === "/";
|
|
4129
|
+
var segments = path.split(separator);
|
|
4130
|
+
if (segment !== void 0 && typeof segment !== "number") {
|
|
4131
|
+
build = v;
|
|
4132
|
+
v = segment;
|
|
4133
|
+
segment = void 0;
|
|
4134
|
+
}
|
|
4135
|
+
if (segment !== void 0 && typeof segment !== "number") {
|
|
4136
|
+
throw new Error('Bad segment "' + segment + '", must be 0-based integer');
|
|
4137
|
+
}
|
|
4138
|
+
if (absolute) {
|
|
4139
|
+
segments.shift();
|
|
4140
|
+
}
|
|
4141
|
+
if (segment < 0) {
|
|
4142
|
+
segment = Math.max(segments.length + segment, 0);
|
|
4143
|
+
}
|
|
4144
|
+
if (v === void 0) {
|
|
4145
|
+
return segment === void 0 ? segments : segments[segment];
|
|
4146
|
+
} else if (segment === null || segments[segment] === void 0) {
|
|
4147
|
+
if (isArray(v)) {
|
|
4148
|
+
segments = [];
|
|
4149
|
+
for (var i = 0, l = v.length; i < l; i++) {
|
|
4150
|
+
if (!v[i].length && (!segments.length || !segments[segments.length - 1].length)) {
|
|
4151
|
+
continue;
|
|
4152
|
+
}
|
|
4153
|
+
if (segments.length && !segments[segments.length - 1].length) {
|
|
4154
|
+
segments.pop();
|
|
4155
|
+
}
|
|
4156
|
+
segments.push(trimSlashes(v[i]));
|
|
4157
|
+
}
|
|
4158
|
+
} else if (v || typeof v === "string") {
|
|
4159
|
+
v = trimSlashes(v);
|
|
4160
|
+
if (segments[segments.length - 1] === "") {
|
|
4161
|
+
segments[segments.length - 1] = v;
|
|
4162
|
+
} else {
|
|
4163
|
+
segments.push(v);
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
} else {
|
|
4167
|
+
if (v) {
|
|
4168
|
+
segments[segment] = trimSlashes(v);
|
|
4169
|
+
} else {
|
|
4170
|
+
segments.splice(segment, 1);
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
if (absolute) {
|
|
4174
|
+
segments.unshift("");
|
|
4175
|
+
}
|
|
4176
|
+
return this.path(segments.join(separator), build);
|
|
4177
|
+
};
|
|
4178
|
+
p.segmentCoded = function(segment, v, build) {
|
|
4179
|
+
var segments, i, l;
|
|
4180
|
+
if (typeof segment !== "number") {
|
|
4181
|
+
build = v;
|
|
4182
|
+
v = segment;
|
|
4183
|
+
segment = void 0;
|
|
4184
|
+
}
|
|
4185
|
+
if (v === void 0) {
|
|
4186
|
+
segments = this.segment(segment, v, build);
|
|
4187
|
+
if (!isArray(segments)) {
|
|
4188
|
+
segments = segments !== void 0 ? URI.decode(segments) : void 0;
|
|
4189
|
+
} else {
|
|
4190
|
+
for (i = 0, l = segments.length; i < l; i++) {
|
|
4191
|
+
segments[i] = URI.decode(segments[i]);
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
return segments;
|
|
4195
|
+
}
|
|
4196
|
+
if (!isArray(v)) {
|
|
4197
|
+
v = typeof v === "string" || v instanceof String ? URI.encode(v) : v;
|
|
4198
|
+
} else {
|
|
4199
|
+
for (i = 0, l = v.length; i < l; i++) {
|
|
4200
|
+
v[i] = URI.encode(v[i]);
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
return this.segment(segment, v, build);
|
|
4204
|
+
};
|
|
4205
|
+
var q = p.query;
|
|
4206
|
+
p.query = function(v, build) {
|
|
4207
|
+
if (v === true) {
|
|
4208
|
+
return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4209
|
+
} else if (typeof v === "function") {
|
|
4210
|
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4211
|
+
var result = v.call(this, data);
|
|
4212
|
+
this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
4213
|
+
this.build(!build);
|
|
4214
|
+
return this;
|
|
4215
|
+
} else if (v !== void 0 && typeof v !== "string") {
|
|
4216
|
+
this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
4217
|
+
this.build(!build);
|
|
4218
|
+
return this;
|
|
4219
|
+
} else {
|
|
4220
|
+
return q.call(this, v, build);
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
p.setQuery = function(name, value, build) {
|
|
4224
|
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4225
|
+
if (typeof name === "string" || name instanceof String) {
|
|
4226
|
+
data[name] = value !== void 0 ? value : null;
|
|
4227
|
+
} else if (typeof name === "object") {
|
|
4228
|
+
for (var key in name) {
|
|
4229
|
+
if (hasOwn.call(name, key)) {
|
|
4230
|
+
data[key] = name[key];
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
} else {
|
|
4234
|
+
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
|
4235
|
+
}
|
|
4236
|
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
4237
|
+
if (typeof name !== "string") {
|
|
4238
|
+
build = value;
|
|
4239
|
+
}
|
|
4240
|
+
this.build(!build);
|
|
4241
|
+
return this;
|
|
4242
|
+
};
|
|
4243
|
+
p.addQuery = function(name, value, build) {
|
|
4244
|
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4245
|
+
URI.addQuery(data, name, value === void 0 ? null : value);
|
|
4246
|
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
4247
|
+
if (typeof name !== "string") {
|
|
4248
|
+
build = value;
|
|
4249
|
+
}
|
|
4250
|
+
this.build(!build);
|
|
4251
|
+
return this;
|
|
4252
|
+
};
|
|
4253
|
+
p.removeQuery = function(name, value, build) {
|
|
4254
|
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4255
|
+
URI.removeQuery(data, name, value);
|
|
4256
|
+
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
4257
|
+
if (typeof name !== "string") {
|
|
4258
|
+
build = value;
|
|
4259
|
+
}
|
|
4260
|
+
this.build(!build);
|
|
4261
|
+
return this;
|
|
4262
|
+
};
|
|
4263
|
+
p.hasQuery = function(name, value, withinArray) {
|
|
4264
|
+
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
4265
|
+
return URI.hasQuery(data, name, value, withinArray);
|
|
4266
|
+
};
|
|
4267
|
+
p.setSearch = p.setQuery;
|
|
4268
|
+
p.addSearch = p.addQuery;
|
|
4269
|
+
p.removeSearch = p.removeQuery;
|
|
4270
|
+
p.hasSearch = p.hasQuery;
|
|
4271
|
+
p.normalize = function() {
|
|
4272
|
+
if (this._parts.urn) {
|
|
4273
|
+
return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
|
|
4274
|
+
}
|
|
4275
|
+
return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
|
|
4276
|
+
};
|
|
4277
|
+
p.normalizeProtocol = function(build) {
|
|
4278
|
+
if (typeof this._parts.protocol === "string") {
|
|
4279
|
+
this._parts.protocol = this._parts.protocol.toLowerCase();
|
|
4280
|
+
this.build(!build);
|
|
4281
|
+
}
|
|
4282
|
+
return this;
|
|
4283
|
+
};
|
|
4284
|
+
p.normalizeHostname = function(build) {
|
|
4285
|
+
if (this._parts.hostname) {
|
|
4286
|
+
if (this.is("IDN") && punycode) {
|
|
4287
|
+
this._parts.hostname = punycode.toASCII(this._parts.hostname);
|
|
4288
|
+
} else if (this.is("IPv6") && IPv6) {
|
|
4289
|
+
this._parts.hostname = IPv6.best(this._parts.hostname);
|
|
4290
|
+
}
|
|
4291
|
+
this._parts.hostname = this._parts.hostname.toLowerCase();
|
|
4292
|
+
this.build(!build);
|
|
4293
|
+
}
|
|
4294
|
+
return this;
|
|
4295
|
+
};
|
|
4296
|
+
p.normalizePort = function(build) {
|
|
4297
|
+
if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
|
|
4298
|
+
this._parts.port = null;
|
|
4299
|
+
this.build(!build);
|
|
4300
|
+
}
|
|
4301
|
+
return this;
|
|
4302
|
+
};
|
|
4303
|
+
p.normalizePath = function(build) {
|
|
4304
|
+
var _path = this._parts.path;
|
|
4305
|
+
if (!_path) {
|
|
4306
|
+
return this;
|
|
4307
|
+
}
|
|
4308
|
+
if (this._parts.urn) {
|
|
4309
|
+
this._parts.path = URI.recodeUrnPath(this._parts.path);
|
|
4310
|
+
this.build(!build);
|
|
4311
|
+
return this;
|
|
4312
|
+
}
|
|
4313
|
+
if (this._parts.path === "/") {
|
|
4314
|
+
return this;
|
|
4315
|
+
}
|
|
4316
|
+
_path = URI.recodePath(_path);
|
|
4317
|
+
var _was_relative;
|
|
4318
|
+
var _leadingParents = "";
|
|
4319
|
+
var _parent, _pos;
|
|
4320
|
+
if (_path.charAt(0) !== "/") {
|
|
4321
|
+
_was_relative = true;
|
|
4322
|
+
_path = "/" + _path;
|
|
4323
|
+
}
|
|
4324
|
+
if (_path.slice(-3) === "/.." || _path.slice(-2) === "/.") {
|
|
4325
|
+
_path += "/";
|
|
4326
|
+
}
|
|
4327
|
+
_path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, "/").replace(/\/{2,}/g, "/");
|
|
4328
|
+
if (_was_relative) {
|
|
4329
|
+
_leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || "";
|
|
4330
|
+
if (_leadingParents) {
|
|
4331
|
+
_leadingParents = _leadingParents[0];
|
|
4332
|
+
}
|
|
4333
|
+
}
|
|
4334
|
+
while (true) {
|
|
4335
|
+
_parent = _path.search(/\/\.\.(\/|$)/);
|
|
4336
|
+
if (_parent === -1) {
|
|
4337
|
+
break;
|
|
4338
|
+
} else if (_parent === 0) {
|
|
4339
|
+
_path = _path.substring(3);
|
|
4340
|
+
continue;
|
|
4341
|
+
}
|
|
4342
|
+
_pos = _path.substring(0, _parent).lastIndexOf("/");
|
|
4343
|
+
if (_pos === -1) {
|
|
4344
|
+
_pos = _parent;
|
|
4345
|
+
}
|
|
4346
|
+
_path = _path.substring(0, _pos) + _path.substring(_parent + 3);
|
|
4347
|
+
}
|
|
4348
|
+
if (_was_relative && this.is("relative")) {
|
|
4349
|
+
_path = _leadingParents + _path.substring(1);
|
|
4350
|
+
}
|
|
4351
|
+
this._parts.path = _path;
|
|
4352
|
+
this.build(!build);
|
|
4353
|
+
return this;
|
|
4354
|
+
};
|
|
4355
|
+
p.normalizePathname = p.normalizePath;
|
|
4356
|
+
p.normalizeQuery = function(build) {
|
|
4357
|
+
if (typeof this._parts.query === "string") {
|
|
4358
|
+
if (!this._parts.query.length) {
|
|
4359
|
+
this._parts.query = null;
|
|
4360
|
+
} else {
|
|
4361
|
+
this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
|
|
4362
|
+
}
|
|
4363
|
+
this.build(!build);
|
|
4364
|
+
}
|
|
4365
|
+
return this;
|
|
4366
|
+
};
|
|
4367
|
+
p.normalizeFragment = function(build) {
|
|
4368
|
+
if (!this._parts.fragment) {
|
|
4369
|
+
this._parts.fragment = null;
|
|
4370
|
+
this.build(!build);
|
|
4371
|
+
}
|
|
4372
|
+
return this;
|
|
4373
|
+
};
|
|
4374
|
+
p.normalizeSearch = p.normalizeQuery;
|
|
4375
|
+
p.normalizeHash = p.normalizeFragment;
|
|
4376
|
+
p.iso8859 = function() {
|
|
4377
|
+
var e = URI.encode;
|
|
4378
|
+
var d = URI.decode;
|
|
4379
|
+
URI.encode = escape;
|
|
4380
|
+
URI.decode = decodeURIComponent;
|
|
4381
|
+
try {
|
|
4382
|
+
this.normalize();
|
|
4383
|
+
} finally {
|
|
4384
|
+
URI.encode = e;
|
|
4385
|
+
URI.decode = d;
|
|
4386
|
+
}
|
|
4387
|
+
return this;
|
|
4388
|
+
};
|
|
4389
|
+
p.unicode = function() {
|
|
4390
|
+
var e = URI.encode;
|
|
4391
|
+
var d = URI.decode;
|
|
4392
|
+
URI.encode = strictEncodeURIComponent;
|
|
4393
|
+
URI.decode = unescape;
|
|
4394
|
+
try {
|
|
4395
|
+
this.normalize();
|
|
4396
|
+
} finally {
|
|
4397
|
+
URI.encode = e;
|
|
4398
|
+
URI.decode = d;
|
|
4399
|
+
}
|
|
4400
|
+
return this;
|
|
4401
|
+
};
|
|
4402
|
+
p.readable = function() {
|
|
4403
|
+
var uri = this.clone();
|
|
4404
|
+
uri.username("").password("").normalize();
|
|
4405
|
+
var t = "";
|
|
4406
|
+
if (uri._parts.protocol) {
|
|
4407
|
+
t += uri._parts.protocol + "://";
|
|
4408
|
+
}
|
|
4409
|
+
if (uri._parts.hostname) {
|
|
4410
|
+
if (uri.is("punycode") && punycode) {
|
|
4411
|
+
t += punycode.toUnicode(uri._parts.hostname);
|
|
4412
|
+
if (uri._parts.port) {
|
|
4413
|
+
t += ":" + uri._parts.port;
|
|
4414
|
+
}
|
|
4415
|
+
} else {
|
|
4416
|
+
t += uri.host();
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== "/") {
|
|
4420
|
+
t += "/";
|
|
4421
|
+
}
|
|
4422
|
+
t += uri.path(true);
|
|
4423
|
+
if (uri._parts.query) {
|
|
4424
|
+
var q2 = "";
|
|
4425
|
+
for (var i = 0, qp = uri._parts.query.split("&"), l = qp.length; i < l; i++) {
|
|
4426
|
+
var kv = (qp[i] || "").split("=");
|
|
4427
|
+
q2 += "&" + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, "%26");
|
|
4428
|
+
if (kv[1] !== void 0) {
|
|
4429
|
+
q2 += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, "%26");
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
t += "?" + q2.substring(1);
|
|
4433
|
+
}
|
|
4434
|
+
t += URI.decodeQuery(uri.hash(), true);
|
|
4435
|
+
return t;
|
|
4436
|
+
};
|
|
4437
|
+
p.absoluteTo = function(base) {
|
|
4438
|
+
var resolved = this.clone();
|
|
4439
|
+
var properties = ["protocol", "username", "password", "hostname", "port"];
|
|
4440
|
+
var basedir, i, p2;
|
|
4441
|
+
if (this._parts.urn) {
|
|
4442
|
+
throw new Error("URNs do not have any generally defined hierarchical components");
|
|
4443
|
+
}
|
|
4444
|
+
if (!(base instanceof URI)) {
|
|
4445
|
+
base = new URI(base);
|
|
4446
|
+
}
|
|
4447
|
+
if (resolved._parts.protocol) {
|
|
4448
|
+
return resolved;
|
|
4449
|
+
} else {
|
|
4450
|
+
resolved._parts.protocol = base._parts.protocol;
|
|
4451
|
+
}
|
|
4452
|
+
if (this._parts.hostname) {
|
|
4453
|
+
return resolved;
|
|
4454
|
+
}
|
|
4455
|
+
for (i = 0; p2 = properties[i]; i++) {
|
|
4456
|
+
resolved._parts[p2] = base._parts[p2];
|
|
4457
|
+
}
|
|
4458
|
+
if (!resolved._parts.path) {
|
|
4459
|
+
resolved._parts.path = base._parts.path;
|
|
4460
|
+
if (!resolved._parts.query) {
|
|
4461
|
+
resolved._parts.query = base._parts.query;
|
|
4462
|
+
}
|
|
4463
|
+
} else {
|
|
4464
|
+
if (resolved._parts.path.substring(-2) === "..") {
|
|
4465
|
+
resolved._parts.path += "/";
|
|
4466
|
+
}
|
|
4467
|
+
if (resolved.path().charAt(0) !== "/") {
|
|
4468
|
+
basedir = base.directory();
|
|
4469
|
+
basedir = basedir ? basedir : base.path().indexOf("/") === 0 ? "/" : "";
|
|
4470
|
+
resolved._parts.path = (basedir ? basedir + "/" : "") + resolved._parts.path;
|
|
4471
|
+
resolved.normalizePath();
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
resolved.build();
|
|
4475
|
+
return resolved;
|
|
4476
|
+
};
|
|
4477
|
+
p.relativeTo = function(base) {
|
|
4478
|
+
var relative = this.clone().normalize();
|
|
4479
|
+
var relativeParts, baseParts, common, relativePath, basePath;
|
|
4480
|
+
if (relative._parts.urn) {
|
|
4481
|
+
throw new Error("URNs do not have any generally defined hierarchical components");
|
|
4482
|
+
}
|
|
4483
|
+
base = new URI(base).normalize();
|
|
4484
|
+
relativeParts = relative._parts;
|
|
4485
|
+
baseParts = base._parts;
|
|
4486
|
+
relativePath = relative.path();
|
|
4487
|
+
basePath = base.path();
|
|
4488
|
+
if (relativePath.charAt(0) !== "/") {
|
|
4489
|
+
throw new Error("URI is already relative");
|
|
4490
|
+
}
|
|
4491
|
+
if (basePath.charAt(0) !== "/") {
|
|
4492
|
+
throw new Error("Cannot calculate a URI relative to another relative URI");
|
|
4493
|
+
}
|
|
4494
|
+
if (relativeParts.protocol === baseParts.protocol) {
|
|
4495
|
+
relativeParts.protocol = null;
|
|
4496
|
+
}
|
|
4497
|
+
if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
|
|
4498
|
+
return relative.build();
|
|
4499
|
+
}
|
|
4500
|
+
if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
|
|
4501
|
+
return relative.build();
|
|
4502
|
+
}
|
|
4503
|
+
if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
|
|
4504
|
+
relativeParts.hostname = null;
|
|
4505
|
+
relativeParts.port = null;
|
|
4506
|
+
} else {
|
|
4507
|
+
return relative.build();
|
|
4508
|
+
}
|
|
4509
|
+
if (relativePath === basePath) {
|
|
4510
|
+
relativeParts.path = "";
|
|
4511
|
+
return relative.build();
|
|
4512
|
+
}
|
|
4513
|
+
common = URI.commonPath(relativePath, basePath);
|
|
4514
|
+
if (!common) {
|
|
4515
|
+
return relative.build();
|
|
4516
|
+
}
|
|
4517
|
+
var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, "").replace(/.*?\//g, "../");
|
|
4518
|
+
relativeParts.path = parents + relativeParts.path.substring(common.length) || "./";
|
|
4519
|
+
return relative.build();
|
|
4520
|
+
};
|
|
4521
|
+
p.equals = function(uri) {
|
|
4522
|
+
var one = this.clone();
|
|
4523
|
+
var two = new URI(uri);
|
|
4524
|
+
var one_map = {};
|
|
4525
|
+
var two_map = {};
|
|
4526
|
+
var checked = {};
|
|
4527
|
+
var one_query, two_query, key;
|
|
4528
|
+
one.normalize();
|
|
4529
|
+
two.normalize();
|
|
4530
|
+
if (one.toString() === two.toString()) {
|
|
4531
|
+
return true;
|
|
4532
|
+
}
|
|
4533
|
+
one_query = one.query();
|
|
4534
|
+
two_query = two.query();
|
|
4535
|
+
one.query("");
|
|
4536
|
+
two.query("");
|
|
4537
|
+
if (one.toString() !== two.toString()) {
|
|
4538
|
+
return false;
|
|
4539
|
+
}
|
|
4540
|
+
if (one_query.length !== two_query.length) {
|
|
4541
|
+
return false;
|
|
4542
|
+
}
|
|
4543
|
+
one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
|
|
4544
|
+
two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
|
|
4545
|
+
for (key in one_map) {
|
|
4546
|
+
if (hasOwn.call(one_map, key)) {
|
|
4547
|
+
if (!isArray(one_map[key])) {
|
|
4548
|
+
if (one_map[key] !== two_map[key]) {
|
|
4549
|
+
return false;
|
|
4550
|
+
}
|
|
4551
|
+
} else if (!arraysEqual(one_map[key], two_map[key])) {
|
|
4552
|
+
return false;
|
|
4553
|
+
}
|
|
4554
|
+
checked[key] = true;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
for (key in two_map) {
|
|
4558
|
+
if (hasOwn.call(two_map, key)) {
|
|
4559
|
+
if (!checked[key]) {
|
|
4560
|
+
return false;
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
}
|
|
4564
|
+
return true;
|
|
4565
|
+
};
|
|
4566
|
+
p.preventInvalidHostname = function(v) {
|
|
4567
|
+
this._parts.preventInvalidHostname = !!v;
|
|
4568
|
+
return this;
|
|
4569
|
+
};
|
|
4570
|
+
p.duplicateQueryParameters = function(v) {
|
|
4571
|
+
this._parts.duplicateQueryParameters = !!v;
|
|
4572
|
+
return this;
|
|
4573
|
+
};
|
|
4574
|
+
p.escapeQuerySpace = function(v) {
|
|
4575
|
+
this._parts.escapeQuerySpace = !!v;
|
|
4576
|
+
return this;
|
|
4577
|
+
};
|
|
4578
|
+
return URI;
|
|
4579
|
+
});
|
|
4580
|
+
}
|
|
4581
|
+
});
|
|
4582
|
+
|
|
2161
4583
|
// ../../node_modules/@magda/tsmonad/dist/monad.js
|
|
2162
4584
|
function eq(a, b) {
|
|
2163
4585
|
var idx = 0;
|
|
@@ -2628,6 +5050,25 @@ function getRequest(_0) {
|
|
|
2628
5050
|
}
|
|
2629
5051
|
});
|
|
2630
5052
|
}
|
|
5053
|
+
|
|
5054
|
+
// ../../magda-typescript-common/dist/getAbsoluteUrl.js
|
|
5055
|
+
var import_urijs = __toESM(require_URI(), 1);
|
|
5056
|
+
function getAbsoluteUrl(url, baseUrl, optionalQueries, allowedUrlHosts) {
|
|
5057
|
+
const uri = (0, import_urijs.default)(url);
|
|
5058
|
+
const urlHost = uri.host();
|
|
5059
|
+
if (urlHost) {
|
|
5060
|
+
if (!allowedUrlHosts || allowedUrlHosts.findIndex((item) => item === urlHost) !== -1) {
|
|
5061
|
+
return url;
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5064
|
+
if (typeof baseUrl !== "string") {
|
|
5065
|
+
baseUrl = "";
|
|
5066
|
+
}
|
|
5067
|
+
const baseUri = (0, import_urijs.default)(baseUrl);
|
|
5068
|
+
const query = uri.search(true);
|
|
5069
|
+
const mergedUri = baseUri.segmentCoded(baseUri.segmentCoded().concat(uri.segmentCoded()));
|
|
5070
|
+
return mergedUri.search(__spreadValues(__spreadValues({}, query ? query : {}), optionalQueries ? optionalQueries : {})).toString();
|
|
5071
|
+
}
|
|
2631
5072
|
export {
|
|
2632
5073
|
AsyncPage,
|
|
2633
5074
|
BadRequestError,
|
|
@@ -2642,6 +5083,7 @@ export {
|
|
|
2642
5083
|
fetchRequest,
|
|
2643
5084
|
forEachAsync,
|
|
2644
5085
|
formatServiceError,
|
|
5086
|
+
getAbsoluteUrl,
|
|
2645
5087
|
getDefaultRequestInitOptions,
|
|
2646
5088
|
getRequest,
|
|
2647
5089
|
getRequestNoCache,
|
|
@@ -2652,3 +5094,52 @@ export {
|
|
|
2652
5094
|
setDefaultRequestInitOptions,
|
|
2653
5095
|
unionToThrowable
|
|
2654
5096
|
};
|
|
5097
|
+
/*! Bundled license information:
|
|
5098
|
+
|
|
5099
|
+
urijs/src/punycode.js:
|
|
5100
|
+
(*! https://mths.be/punycode v1.4.0 by @mathias *)
|
|
5101
|
+
|
|
5102
|
+
urijs/src/IPv6.js:
|
|
5103
|
+
(*!
|
|
5104
|
+
* URI.js - Mutating URLs
|
|
5105
|
+
* IPv6 Support
|
|
5106
|
+
*
|
|
5107
|
+
* Version: 1.19.11
|
|
5108
|
+
*
|
|
5109
|
+
* Author: Rodney Rehm
|
|
5110
|
+
* Web: http://medialize.github.io/URI.js/
|
|
5111
|
+
*
|
|
5112
|
+
* Licensed under
|
|
5113
|
+
* MIT License http://www.opensource.org/licenses/mit-license
|
|
5114
|
+
*
|
|
5115
|
+
*)
|
|
5116
|
+
|
|
5117
|
+
urijs/src/SecondLevelDomains.js:
|
|
5118
|
+
(*!
|
|
5119
|
+
* URI.js - Mutating URLs
|
|
5120
|
+
* Second Level Domain (SLD) Support
|
|
5121
|
+
*
|
|
5122
|
+
* Version: 1.19.11
|
|
5123
|
+
*
|
|
5124
|
+
* Author: Rodney Rehm
|
|
5125
|
+
* Web: http://medialize.github.io/URI.js/
|
|
5126
|
+
*
|
|
5127
|
+
* Licensed under
|
|
5128
|
+
* MIT License http://www.opensource.org/licenses/mit-license
|
|
5129
|
+
*
|
|
5130
|
+
*)
|
|
5131
|
+
|
|
5132
|
+
urijs/src/URI.js:
|
|
5133
|
+
(*!
|
|
5134
|
+
* URI.js - Mutating URLs
|
|
5135
|
+
*
|
|
5136
|
+
* Version: 1.19.11
|
|
5137
|
+
*
|
|
5138
|
+
* Author: Rodney Rehm
|
|
5139
|
+
* Web: http://medialize.github.io/URI.js/
|
|
5140
|
+
*
|
|
5141
|
+
* Licensed under
|
|
5142
|
+
* MIT License http://www.opensource.org/licenses/mit-license
|
|
5143
|
+
*
|
|
5144
|
+
*)
|
|
5145
|
+
*/
|