@hyperjump/json-schema 0.18.5 → 0.19.0
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/json-schema-amd.js +1384 -194
- package/dist/json-schema-amd.js.map +1 -1
- package/dist/json-schema-amd.min.js +3 -1
- package/dist/json-schema-amd.min.js.map +1 -1
- package/dist/json-schema-cjs.js +1384 -194
- package/dist/json-schema-cjs.js.map +1 -1
- package/dist/json-schema-cjs.min.js +3 -1
- package/dist/json-schema-cjs.min.js.map +1 -1
- package/dist/json-schema-esm.js +1384 -194
- package/dist/json-schema-esm.js.map +1 -1
- package/dist/json-schema-esm.min.js +3 -1
- package/dist/json-schema-esm.min.js.map +1 -1
- package/dist/json-schema-iife.js +1384 -194
- package/dist/json-schema-iife.js.map +1 -1
- package/dist/json-schema-iife.min.js +3 -1
- package/dist/json-schema-iife.min.js.map +1 -1
- package/dist/json-schema-system.js +1384 -194
- package/dist/json-schema-system.js.map +1 -1
- package/dist/json-schema-system.min.js +3 -1
- package/dist/json-schema-system.min.js.map +1 -1
- package/dist/json-schema-umd.js +1384 -194
- package/dist/json-schema-umd.js.map +1 -1
- package/dist/json-schema-umd.min.js +3 -1
- package/dist/json-schema-umd.min.js.map +1 -1
- package/package.json +2 -2
package/dist/json-schema-amd.js
CHANGED
|
@@ -43,6 +43,10 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
43
43
|
|
|
44
44
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
45
45
|
|
|
46
|
+
function unwrapExports (x) {
|
|
47
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
function createCommonjsModule(fn, module) {
|
|
47
51
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
48
52
|
}
|
|
@@ -402,216 +406,1412 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
402
406
|
});
|
|
403
407
|
pubsub.PubSub;
|
|
404
408
|
|
|
405
|
-
var
|
|
409
|
+
var uri_all = createCommonjsModule(function (module, exports) {
|
|
410
|
+
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
|
|
411
|
+
(function (global, factory) {
|
|
412
|
+
factory(exports) ;
|
|
413
|
+
}(commonjsGlobal, (function (exports) {
|
|
414
|
+
function merge() {
|
|
415
|
+
for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
|
|
416
|
+
sets[_key] = arguments[_key];
|
|
417
|
+
}
|
|
406
418
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
419
|
+
if (sets.length > 1) {
|
|
420
|
+
sets[0] = sets[0].slice(0, -1);
|
|
421
|
+
var xl = sets.length - 1;
|
|
422
|
+
for (var x = 1; x < xl; ++x) {
|
|
423
|
+
sets[x] = sets[x].slice(1, -1);
|
|
424
|
+
}
|
|
425
|
+
sets[xl] = sets[xl].slice(1);
|
|
426
|
+
return sets.join('');
|
|
427
|
+
} else {
|
|
428
|
+
return sets[0];
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function subexp(str) {
|
|
432
|
+
return "(?:" + str + ")";
|
|
433
|
+
}
|
|
434
|
+
function typeOf(o) {
|
|
435
|
+
return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
|
|
436
|
+
}
|
|
437
|
+
function toUpperCase(str) {
|
|
438
|
+
return str.toUpperCase();
|
|
439
|
+
}
|
|
440
|
+
function toArray(obj) {
|
|
441
|
+
return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
|
|
442
|
+
}
|
|
443
|
+
function assign(target, source) {
|
|
444
|
+
var obj = target;
|
|
445
|
+
if (source) {
|
|
446
|
+
for (var key in source) {
|
|
447
|
+
obj[key] = source[key];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return obj;
|
|
451
|
+
}
|
|
411
452
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
453
|
+
function buildExps(isIRI) {
|
|
454
|
+
var ALPHA$$ = "[A-Za-z]",
|
|
455
|
+
DIGIT$$ = "[0-9]",
|
|
456
|
+
HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
|
|
457
|
+
PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
|
|
458
|
+
//expanded
|
|
459
|
+
GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
|
|
460
|
+
SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
|
|
461
|
+
RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
|
|
462
|
+
UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
|
|
463
|
+
//subset, excludes bidi control characters
|
|
464
|
+
IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
|
|
465
|
+
//subset
|
|
466
|
+
UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$);
|
|
467
|
+
subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*");
|
|
468
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*");
|
|
469
|
+
var DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
|
|
470
|
+
//relaxed parsing rules
|
|
471
|
+
IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
|
|
472
|
+
H16$ = subexp(HEXDIG$$ + "{1,4}"),
|
|
473
|
+
LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
|
|
474
|
+
IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
|
|
475
|
+
// 6( h16 ":" ) ls32
|
|
476
|
+
IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
|
|
477
|
+
// "::" 5( h16 ":" ) ls32
|
|
478
|
+
IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
|
|
479
|
+
//[ h16 ] "::" 4( h16 ":" ) ls32
|
|
480
|
+
IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
|
|
481
|
+
//[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
|
|
482
|
+
IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
|
|
483
|
+
//[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
|
|
484
|
+
IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
|
|
485
|
+
//[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
|
|
486
|
+
IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
|
|
487
|
+
//[ *4( h16 ":" ) h16 ] "::" ls32
|
|
488
|
+
IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
|
|
489
|
+
//[ *5( h16 ":" ) h16 ] "::" h16
|
|
490
|
+
IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
|
|
491
|
+
//[ *6( h16 ":" ) h16 ] "::"
|
|
492
|
+
IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
|
|
493
|
+
ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+");
|
|
494
|
+
//RFC 6874, with relaxed parsing rules
|
|
495
|
+
subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+");
|
|
496
|
+
//RFC 6874
|
|
497
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*");
|
|
498
|
+
var PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]"));
|
|
499
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+");
|
|
500
|
+
subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*");
|
|
501
|
+
return {
|
|
502
|
+
NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
|
|
503
|
+
NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
504
|
+
NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
505
|
+
NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
506
|
+
NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
507
|
+
NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
|
|
508
|
+
NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
|
|
509
|
+
ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
510
|
+
UNRESERVED: new RegExp(UNRESERVED$$, "g"),
|
|
511
|
+
OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
|
|
512
|
+
PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
|
|
513
|
+
IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
|
|
514
|
+
IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
|
|
515
|
+
};
|
|
415
516
|
}
|
|
517
|
+
var URI_PROTOCOL = buildExps(false);
|
|
416
518
|
|
|
417
|
-
|
|
418
|
-
function _pathResolve (path) {
|
|
419
|
-
let pathSplit = path.split('/');
|
|
519
|
+
var IRI_PROTOCOL = buildExps(true);
|
|
420
520
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
521
|
+
var slicedToArray = function () {
|
|
522
|
+
function sliceIterator(arr, i) {
|
|
523
|
+
var _arr = [];
|
|
524
|
+
var _n = true;
|
|
525
|
+
var _d = false;
|
|
526
|
+
var _e = undefined;
|
|
425
527
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
528
|
+
try {
|
|
529
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
530
|
+
_arr.push(_s.value);
|
|
531
|
+
|
|
532
|
+
if (i && _arr.length === i) break;
|
|
533
|
+
}
|
|
534
|
+
} catch (err) {
|
|
535
|
+
_d = true;
|
|
536
|
+
_e = err;
|
|
537
|
+
} finally {
|
|
538
|
+
try {
|
|
539
|
+
if (!_n && _i["return"]) _i["return"]();
|
|
540
|
+
} finally {
|
|
541
|
+
if (_d) throw _e;
|
|
435
542
|
}
|
|
436
543
|
}
|
|
437
|
-
});
|
|
438
|
-
return '/' + resultArray.join('/');
|
|
439
|
-
}
|
|
440
544
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
545
|
+
return _arr;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return function (arr, i) {
|
|
549
|
+
if (Array.isArray(arr)) {
|
|
550
|
+
return arr;
|
|
551
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
552
|
+
return sliceIterator(arr, i);
|
|
553
|
+
} else {
|
|
554
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
555
|
+
}
|
|
448
556
|
};
|
|
557
|
+
}();
|
|
449
558
|
|
|
450
|
-
let path = base;
|
|
451
|
-
let protocolEndIndex = base.indexOf('//');
|
|
452
559
|
|
|
453
|
-
resultObject.protocol = path.substring(0, protocolEndIndex);
|
|
454
560
|
|
|
455
|
-
protocolEndIndex += 2; // add two to pass double slash
|
|
456
561
|
|
|
457
|
-
const pathIndex = base.indexOf('/', protocolEndIndex);
|
|
458
|
-
const queryIndex = base.indexOf('?');
|
|
459
|
-
const hashIndex = base.indexOf('#');
|
|
460
562
|
|
|
461
|
-
if (hashIndex !== -1) {
|
|
462
|
-
path = path.substring(0, hashIndex); // remove hash, not needed for base
|
|
463
|
-
}
|
|
464
563
|
|
|
465
|
-
if (queryIndex !== -1) {
|
|
466
|
-
const query = path.substring(queryIndex); // remove query, save in return obj
|
|
467
|
-
resultObject.query = query;
|
|
468
|
-
path = path.substring(0, queryIndex);
|
|
469
|
-
}
|
|
470
564
|
|
|
471
|
-
if (pathIndex !== -1) {
|
|
472
|
-
const host = path.substring(0, pathIndex); // separate host & path
|
|
473
|
-
resultObject.host = host;
|
|
474
|
-
path = path.substring(pathIndex);
|
|
475
|
-
resultObject.path = path;
|
|
476
|
-
} else {
|
|
477
|
-
resultObject.host = path; // there was no path, therefore path is host
|
|
478
|
-
}
|
|
479
565
|
|
|
480
|
-
return resultObject;
|
|
481
|
-
}
|
|
482
566
|
|
|
483
|
-
// https://tools.ietf.org/html/rfc3986#section-3.1
|
|
484
|
-
const _scheme = '[a-z][a-z0-9+.-]*'; // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )]
|
|
485
|
-
const _isAbsolute = new RegExp(`^(${_scheme}:)?//`, 'i');
|
|
486
|
-
|
|
487
|
-
// parses a relative url string into an object containing the href,
|
|
488
|
-
// hash, query and whether it is a net path, absolute path or relative path
|
|
489
|
-
function _relativeParse (relative) {
|
|
490
|
-
const resultObject = {
|
|
491
|
-
href: relative, // href is always what was passed through
|
|
492
|
-
hash: '',
|
|
493
|
-
query: '',
|
|
494
|
-
netPath: false,
|
|
495
|
-
absolutePath: false,
|
|
496
|
-
relativePath: false
|
|
497
|
-
};
|
|
498
|
-
// check for protocol
|
|
499
|
-
// if protocol exists, is net path (absolute URL)
|
|
500
|
-
if (_isAbsolute.test(relative)) {
|
|
501
|
-
resultObject.netPath = true;
|
|
502
|
-
// return, in this case the relative is the resolved url, no need to parse.
|
|
503
|
-
return resultObject;
|
|
504
|
-
}
|
|
505
567
|
|
|
506
|
-
// if / is first, this is an absolute path,
|
|
507
|
-
// I.E. it overwrites the base URL's path
|
|
508
|
-
if (relative[0] === '/') {
|
|
509
|
-
resultObject.absolutePath = true;
|
|
510
|
-
// return resultObject
|
|
511
|
-
} else if (relative !== '') {
|
|
512
|
-
resultObject.relativePath = true;
|
|
513
|
-
}
|
|
514
568
|
|
|
515
|
-
let path = relative;
|
|
516
|
-
const queryIndex = relative.indexOf('?');
|
|
517
|
-
const hashIndex = relative.indexOf('#');
|
|
518
569
|
|
|
519
|
-
if (hashIndex !== -1) {
|
|
520
|
-
const hash = path.substring(hashIndex);
|
|
521
|
-
resultObject.hash = hash;
|
|
522
|
-
path = path.substring(0, hashIndex);
|
|
523
|
-
}
|
|
524
570
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
571
|
+
var toConsumableArray = function (arr) {
|
|
572
|
+
if (Array.isArray(arr)) {
|
|
573
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
574
|
+
|
|
575
|
+
return arr2;
|
|
576
|
+
} else {
|
|
577
|
+
return Array.from(arr);
|
|
529
578
|
}
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
/** Highest positive signed 32-bit float value */
|
|
582
|
+
|
|
583
|
+
var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
|
584
|
+
|
|
585
|
+
/** Bootstring parameters */
|
|
586
|
+
var base = 36;
|
|
587
|
+
var tMin = 1;
|
|
588
|
+
var tMax = 26;
|
|
589
|
+
var skew = 38;
|
|
590
|
+
var damp = 700;
|
|
591
|
+
var initialBias = 72;
|
|
592
|
+
var initialN = 128; // 0x80
|
|
593
|
+
var delimiter = '-'; // '\x2D'
|
|
594
|
+
|
|
595
|
+
/** Regular expressions */
|
|
596
|
+
var regexPunycode = /^xn--/;
|
|
597
|
+
var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
|
|
598
|
+
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
|
|
599
|
+
|
|
600
|
+
/** Error messages */
|
|
601
|
+
var errors = {
|
|
602
|
+
'overflow': 'Overflow: input needs wider integers to process',
|
|
603
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
604
|
+
'invalid-input': 'Invalid input'
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
/** Convenience shortcuts */
|
|
608
|
+
var baseMinusTMin = base - tMin;
|
|
609
|
+
var floor = Math.floor;
|
|
610
|
+
var stringFromCharCode = String.fromCharCode;
|
|
530
611
|
|
|
531
|
-
|
|
532
|
-
|
|
612
|
+
/*--------------------------------------------------------------------------*/
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* A generic error utility function.
|
|
616
|
+
* @private
|
|
617
|
+
* @param {String} type The error type.
|
|
618
|
+
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
|
619
|
+
*/
|
|
620
|
+
function error$1(type) {
|
|
621
|
+
throw new RangeError(errors[type]);
|
|
533
622
|
}
|
|
534
623
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
624
|
+
/**
|
|
625
|
+
* A generic `Array#map` utility function.
|
|
626
|
+
* @private
|
|
627
|
+
* @param {Array} array The array to iterate over.
|
|
628
|
+
* @param {Function} callback The function that gets called for every array
|
|
629
|
+
* item.
|
|
630
|
+
* @returns {Array} A new array of values returned by the callback function.
|
|
631
|
+
*/
|
|
632
|
+
function map(array, fn) {
|
|
633
|
+
var result = [];
|
|
634
|
+
var length = array.length;
|
|
635
|
+
while (length--) {
|
|
636
|
+
result[length] = fn(array[length]);
|
|
637
|
+
}
|
|
638
|
+
return result;
|
|
541
639
|
}
|
|
542
640
|
|
|
543
|
-
|
|
544
|
-
|
|
641
|
+
/**
|
|
642
|
+
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
|
643
|
+
* addresses.
|
|
644
|
+
* @private
|
|
645
|
+
* @param {String} domain The domain name or email address.
|
|
646
|
+
* @param {Function} callback The function that gets called for every
|
|
647
|
+
* character.
|
|
648
|
+
* @returns {Array} A new string of characters returned by the callback
|
|
649
|
+
* function.
|
|
650
|
+
*/
|
|
651
|
+
function mapDomain(string, fn) {
|
|
652
|
+
var parts = string.split('@');
|
|
653
|
+
var result = '';
|
|
654
|
+
if (parts.length > 1) {
|
|
655
|
+
// In email addresses, only the domain name should be punycoded. Leave
|
|
656
|
+
// the local part (i.e. everything up to `@`) intact.
|
|
657
|
+
result = parts[0] + '@';
|
|
658
|
+
string = parts[1];
|
|
659
|
+
}
|
|
660
|
+
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
|
661
|
+
string = string.replace(regexSeparators, '\x2E');
|
|
662
|
+
var labels = string.split('.');
|
|
663
|
+
var encoded = map(labels, fn).join('.');
|
|
664
|
+
return result + encoded;
|
|
545
665
|
}
|
|
546
666
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
667
|
+
/**
|
|
668
|
+
* Creates an array containing the numeric code points of each Unicode
|
|
669
|
+
* character in the string. While JavaScript uses UCS-2 internally,
|
|
670
|
+
* this function will convert a pair of surrogate halves (each of which
|
|
671
|
+
* UCS-2 exposes as separate characters) into a single code point,
|
|
672
|
+
* matching UTF-16.
|
|
673
|
+
* @see `punycode.ucs2.encode`
|
|
674
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
675
|
+
* @memberOf punycode.ucs2
|
|
676
|
+
* @name decode
|
|
677
|
+
* @param {String} string The Unicode input string (UCS-2).
|
|
678
|
+
* @returns {Array} The new array of code points.
|
|
679
|
+
*/
|
|
680
|
+
function ucs2decode(string) {
|
|
681
|
+
var output = [];
|
|
682
|
+
var counter = 0;
|
|
683
|
+
var length = string.length;
|
|
684
|
+
while (counter < length) {
|
|
685
|
+
var value = string.charCodeAt(counter++);
|
|
686
|
+
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
687
|
+
// It's a high surrogate, and there is a next character.
|
|
688
|
+
var extra = string.charCodeAt(counter++);
|
|
689
|
+
if ((extra & 0xFC00) == 0xDC00) {
|
|
690
|
+
// Low surrogate.
|
|
691
|
+
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
692
|
+
} else {
|
|
693
|
+
// It's an unmatched surrogate; only append this code unit, in case the
|
|
694
|
+
// next code unit is the high surrogate of a surrogate pair.
|
|
695
|
+
output.push(value);
|
|
696
|
+
counter--;
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
output.push(value);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return output;
|
|
703
|
+
}
|
|
555
704
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
705
|
+
/**
|
|
706
|
+
* Creates a string based on an array of numeric code points.
|
|
707
|
+
* @see `punycode.ucs2.decode`
|
|
708
|
+
* @memberOf punycode.ucs2
|
|
709
|
+
* @name encode
|
|
710
|
+
* @param {Array} codePoints The array of numeric code points.
|
|
711
|
+
* @returns {String} The new Unicode string (UCS-2).
|
|
712
|
+
*/
|
|
713
|
+
var ucs2encode = function ucs2encode(array) {
|
|
714
|
+
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
715
|
+
};
|
|
560
716
|
|
|
561
|
-
|
|
562
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Converts a basic code point into a digit/integer.
|
|
719
|
+
* @see `digitToBasic()`
|
|
720
|
+
* @private
|
|
721
|
+
* @param {Number} codePoint The basic numeric code point value.
|
|
722
|
+
* @returns {Number} The numeric value of a basic code point (for use in
|
|
723
|
+
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
724
|
+
* the code point does not represent a value.
|
|
725
|
+
*/
|
|
726
|
+
var basicToDigit = function basicToDigit(codePoint) {
|
|
727
|
+
if (codePoint - 0x30 < 0x0A) {
|
|
728
|
+
return codePoint - 0x16;
|
|
729
|
+
}
|
|
730
|
+
if (codePoint - 0x41 < 0x1A) {
|
|
731
|
+
return codePoint - 0x41;
|
|
732
|
+
}
|
|
733
|
+
if (codePoint - 0x61 < 0x1A) {
|
|
734
|
+
return codePoint - 0x61;
|
|
735
|
+
}
|
|
736
|
+
return base;
|
|
737
|
+
};
|
|
563
738
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
739
|
+
/**
|
|
740
|
+
* Converts a digit/integer into a basic code point.
|
|
741
|
+
* @see `basicToDigit()`
|
|
742
|
+
* @private
|
|
743
|
+
* @param {Number} digit The numeric value of a basic code point.
|
|
744
|
+
* @returns {Number} The basic code point whose value (when used for
|
|
745
|
+
* representing integers) is `digit`, which needs to be in the range
|
|
746
|
+
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
747
|
+
* used; else, the lowercase form is used. The behavior is undefined
|
|
748
|
+
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
749
|
+
*/
|
|
750
|
+
var digitToBasic = function digitToBasic(digit, flag) {
|
|
751
|
+
// 0..25 map to ASCII a..z or A..Z
|
|
752
|
+
// 26..35 map to ASCII 0..9
|
|
753
|
+
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
758
|
+
* https://tools.ietf.org/html/rfc3492#section-3.4
|
|
759
|
+
* @private
|
|
760
|
+
*/
|
|
761
|
+
var adapt = function adapt(delta, numPoints, firstTime) {
|
|
762
|
+
var k = 0;
|
|
763
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
764
|
+
delta += floor(delta / numPoints);
|
|
765
|
+
for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
766
|
+
delta = floor(delta / baseMinusTMin);
|
|
767
|
+
}
|
|
768
|
+
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
773
|
+
* symbols.
|
|
774
|
+
* @memberOf punycode
|
|
775
|
+
* @param {String} input The Punycode string of ASCII-only symbols.
|
|
776
|
+
* @returns {String} The resulting string of Unicode symbols.
|
|
777
|
+
*/
|
|
778
|
+
var decode = function decode(input) {
|
|
779
|
+
// Don't use UCS-2.
|
|
780
|
+
var output = [];
|
|
781
|
+
var inputLength = input.length;
|
|
782
|
+
var i = 0;
|
|
783
|
+
var n = initialN;
|
|
784
|
+
var bias = initialBias;
|
|
785
|
+
|
|
786
|
+
// Handle the basic code points: let `basic` be the number of input code
|
|
787
|
+
// points before the last delimiter, or `0` if there is none, then copy
|
|
788
|
+
// the first basic code points to the output.
|
|
789
|
+
|
|
790
|
+
var basic = input.lastIndexOf(delimiter);
|
|
791
|
+
if (basic < 0) {
|
|
792
|
+
basic = 0;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
for (var j = 0; j < basic; ++j) {
|
|
796
|
+
// if it's not a basic code point
|
|
797
|
+
if (input.charCodeAt(j) >= 0x80) {
|
|
798
|
+
error$1('not-basic');
|
|
799
|
+
}
|
|
800
|
+
output.push(input.charCodeAt(j));
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// Main decoding loop: start just after the last delimiter if any basic code
|
|
804
|
+
// points were copied; start at the beginning otherwise.
|
|
805
|
+
|
|
806
|
+
for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
|
|
807
|
+
|
|
808
|
+
// `index` is the index of the next character to be consumed.
|
|
809
|
+
// Decode a generalized variable-length integer into `delta`,
|
|
810
|
+
// which gets added to `i`. The overflow checking is easier
|
|
811
|
+
// if we increase `i` as we go, then subtract off its starting
|
|
812
|
+
// value at the end to obtain `delta`.
|
|
813
|
+
var oldi = i;
|
|
814
|
+
for (var w = 1, k = base;; /* no condition */k += base) {
|
|
815
|
+
|
|
816
|
+
if (index >= inputLength) {
|
|
817
|
+
error$1('invalid-input');
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
var digit = basicToDigit(input.charCodeAt(index++));
|
|
821
|
+
|
|
822
|
+
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
823
|
+
error$1('overflow');
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
i += digit * w;
|
|
827
|
+
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
828
|
+
|
|
829
|
+
if (digit < t) {
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
var baseMinusT = base - t;
|
|
834
|
+
if (w > floor(maxInt / baseMinusT)) {
|
|
835
|
+
error$1('overflow');
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
w *= baseMinusT;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
var out = output.length + 1;
|
|
842
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
|
843
|
+
|
|
844
|
+
// `i` was supposed to wrap around from `out` to `0`,
|
|
845
|
+
// incrementing `n` each time, so we'll fix that now:
|
|
846
|
+
if (floor(i / out) > maxInt - n) {
|
|
847
|
+
error$1('overflow');
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
n += floor(i / out);
|
|
851
|
+
i %= out;
|
|
852
|
+
|
|
853
|
+
// Insert `n` at position `i` of the output.
|
|
854
|
+
output.splice(i++, 0, n);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return String.fromCodePoint.apply(String, output);
|
|
858
|
+
};
|
|
567
859
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
862
|
+
* Punycode string of ASCII-only symbols.
|
|
863
|
+
* @memberOf punycode
|
|
864
|
+
* @param {String} input The string of Unicode symbols.
|
|
865
|
+
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
|
866
|
+
*/
|
|
867
|
+
var encode = function encode(input) {
|
|
868
|
+
var output = [];
|
|
869
|
+
|
|
870
|
+
// Convert the input in UCS-2 to an array of Unicode code points.
|
|
871
|
+
input = ucs2decode(input);
|
|
872
|
+
|
|
873
|
+
// Cache the length.
|
|
874
|
+
var inputLength = input.length;
|
|
875
|
+
|
|
876
|
+
// Initialize the state.
|
|
877
|
+
var n = initialN;
|
|
878
|
+
var delta = 0;
|
|
879
|
+
var bias = initialBias;
|
|
880
|
+
|
|
881
|
+
// Handle the basic code points.
|
|
882
|
+
var _iteratorNormalCompletion = true;
|
|
883
|
+
var _didIteratorError = false;
|
|
884
|
+
var _iteratorError = undefined;
|
|
885
|
+
|
|
886
|
+
try {
|
|
887
|
+
for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
888
|
+
var _currentValue2 = _step.value;
|
|
889
|
+
|
|
890
|
+
if (_currentValue2 < 0x80) {
|
|
891
|
+
output.push(stringFromCharCode(_currentValue2));
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
} catch (err) {
|
|
895
|
+
_didIteratorError = true;
|
|
896
|
+
_iteratorError = err;
|
|
897
|
+
} finally {
|
|
898
|
+
try {
|
|
899
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
900
|
+
_iterator.return();
|
|
901
|
+
}
|
|
902
|
+
} finally {
|
|
903
|
+
if (_didIteratorError) {
|
|
904
|
+
throw _iteratorError;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
var basicLength = output.length;
|
|
910
|
+
var handledCPCount = basicLength;
|
|
911
|
+
|
|
912
|
+
// `handledCPCount` is the number of code points that have been handled;
|
|
913
|
+
// `basicLength` is the number of basic code points.
|
|
914
|
+
|
|
915
|
+
// Finish the basic string with a delimiter unless it's empty.
|
|
916
|
+
if (basicLength) {
|
|
917
|
+
output.push(delimiter);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Main encoding loop:
|
|
921
|
+
while (handledCPCount < inputLength) {
|
|
922
|
+
|
|
923
|
+
// All non-basic code points < n have been handled already. Find the next
|
|
924
|
+
// larger one:
|
|
925
|
+
var m = maxInt;
|
|
926
|
+
var _iteratorNormalCompletion2 = true;
|
|
927
|
+
var _didIteratorError2 = false;
|
|
928
|
+
var _iteratorError2 = undefined;
|
|
929
|
+
|
|
930
|
+
try {
|
|
931
|
+
for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
932
|
+
var currentValue = _step2.value;
|
|
933
|
+
|
|
934
|
+
if (currentValue >= n && currentValue < m) {
|
|
935
|
+
m = currentValue;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
940
|
+
// but guard against overflow.
|
|
941
|
+
} catch (err) {
|
|
942
|
+
_didIteratorError2 = true;
|
|
943
|
+
_iteratorError2 = err;
|
|
944
|
+
} finally {
|
|
945
|
+
try {
|
|
946
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
947
|
+
_iterator2.return();
|
|
948
|
+
}
|
|
949
|
+
} finally {
|
|
950
|
+
if (_didIteratorError2) {
|
|
951
|
+
throw _iteratorError2;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
var handledCPCountPlusOne = handledCPCount + 1;
|
|
957
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
958
|
+
error$1('overflow');
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
962
|
+
n = m;
|
|
963
|
+
|
|
964
|
+
var _iteratorNormalCompletion3 = true;
|
|
965
|
+
var _didIteratorError3 = false;
|
|
966
|
+
var _iteratorError3 = undefined;
|
|
967
|
+
|
|
968
|
+
try {
|
|
969
|
+
for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
970
|
+
var _currentValue = _step3.value;
|
|
971
|
+
|
|
972
|
+
if (_currentValue < n && ++delta > maxInt) {
|
|
973
|
+
error$1('overflow');
|
|
974
|
+
}
|
|
975
|
+
if (_currentValue == n) {
|
|
976
|
+
// Represent delta as a generalized variable-length integer.
|
|
977
|
+
var q = delta;
|
|
978
|
+
for (var k = base;; /* no condition */k += base) {
|
|
979
|
+
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
980
|
+
if (q < t) {
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
var qMinusT = q - t;
|
|
984
|
+
var baseMinusT = base - t;
|
|
985
|
+
output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
|
|
986
|
+
q = floor(qMinusT / baseMinusT);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
990
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
991
|
+
delta = 0;
|
|
992
|
+
++handledCPCount;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
} catch (err) {
|
|
996
|
+
_didIteratorError3 = true;
|
|
997
|
+
_iteratorError3 = err;
|
|
998
|
+
} finally {
|
|
999
|
+
try {
|
|
1000
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
1001
|
+
_iterator3.return();
|
|
1002
|
+
}
|
|
1003
|
+
} finally {
|
|
1004
|
+
if (_didIteratorError3) {
|
|
1005
|
+
throw _iteratorError3;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
++delta;
|
|
1011
|
+
++n;
|
|
1012
|
+
}
|
|
1013
|
+
return output.join('');
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Converts a Punycode string representing a domain name or an email address
|
|
1018
|
+
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
|
1019
|
+
* it doesn't matter if you call it on a string that has already been
|
|
1020
|
+
* converted to Unicode.
|
|
1021
|
+
* @memberOf punycode
|
|
1022
|
+
* @param {String} input The Punycoded domain name or email address to
|
|
1023
|
+
* convert to Unicode.
|
|
1024
|
+
* @returns {String} The Unicode representation of the given Punycode
|
|
1025
|
+
* string.
|
|
1026
|
+
*/
|
|
1027
|
+
var toUnicode = function toUnicode(input) {
|
|
1028
|
+
return mapDomain(input, function (string) {
|
|
1029
|
+
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
1030
|
+
});
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Converts a Unicode string representing a domain name or an email address to
|
|
1035
|
+
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
1036
|
+
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
1037
|
+
* ASCII.
|
|
1038
|
+
* @memberOf punycode
|
|
1039
|
+
* @param {String} input The domain name or email address to convert, as a
|
|
1040
|
+
* Unicode string.
|
|
1041
|
+
* @returns {String} The Punycode representation of the given domain name or
|
|
1042
|
+
* email address.
|
|
1043
|
+
*/
|
|
1044
|
+
var toASCII = function toASCII(input) {
|
|
1045
|
+
return mapDomain(input, function (string) {
|
|
1046
|
+
return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
/*--------------------------------------------------------------------------*/
|
|
1051
|
+
|
|
1052
|
+
/** Define the public API */
|
|
1053
|
+
var punycode = {
|
|
1054
|
+
/**
|
|
1055
|
+
* A string representing the current Punycode.js version number.
|
|
1056
|
+
* @memberOf punycode
|
|
1057
|
+
* @type String
|
|
1058
|
+
*/
|
|
1059
|
+
'version': '2.1.0',
|
|
1060
|
+
/**
|
|
1061
|
+
* An object of methods to convert from JavaScript's internal character
|
|
1062
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
1063
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
1064
|
+
* @memberOf punycode
|
|
1065
|
+
* @type Object
|
|
1066
|
+
*/
|
|
1067
|
+
'ucs2': {
|
|
1068
|
+
'decode': ucs2decode,
|
|
1069
|
+
'encode': ucs2encode
|
|
1070
|
+
},
|
|
1071
|
+
'decode': decode,
|
|
1072
|
+
'encode': encode,
|
|
1073
|
+
'toASCII': toASCII,
|
|
1074
|
+
'toUnicode': toUnicode
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* URI.js
|
|
1079
|
+
*
|
|
1080
|
+
* @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
|
|
1081
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
|
1082
|
+
* @see http://github.com/garycourt/uri-js
|
|
1083
|
+
*/
|
|
1084
|
+
/**
|
|
1085
|
+
* Copyright 2011 Gary Court. All rights reserved.
|
|
1086
|
+
*
|
|
1087
|
+
* Redistribution and use in source and binary forms, with or without modification, are
|
|
1088
|
+
* permitted provided that the following conditions are met:
|
|
1089
|
+
*
|
|
1090
|
+
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
1091
|
+
* conditions and the following disclaimer.
|
|
1092
|
+
*
|
|
1093
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
1094
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
1095
|
+
* provided with the distribution.
|
|
1096
|
+
*
|
|
1097
|
+
* THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
1098
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1099
|
+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
|
|
1100
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
1101
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1102
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
1103
|
+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1104
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
1105
|
+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1106
|
+
*
|
|
1107
|
+
* The views and conclusions contained in the software and documentation are those of the
|
|
1108
|
+
* authors and should not be interpreted as representing official policies, either expressed
|
|
1109
|
+
* or implied, of Gary Court.
|
|
1110
|
+
*/
|
|
1111
|
+
var SCHEMES = {};
|
|
1112
|
+
function pctEncChar(chr) {
|
|
1113
|
+
var c = chr.charCodeAt(0);
|
|
1114
|
+
var e = void 0;
|
|
1115
|
+
if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
|
|
1116
|
+
return e;
|
|
1117
|
+
}
|
|
1118
|
+
function pctDecChars(str) {
|
|
1119
|
+
var newStr = "";
|
|
1120
|
+
var i = 0;
|
|
1121
|
+
var il = str.length;
|
|
1122
|
+
while (i < il) {
|
|
1123
|
+
var c = parseInt(str.substr(i + 1, 2), 16);
|
|
1124
|
+
if (c < 128) {
|
|
1125
|
+
newStr += String.fromCharCode(c);
|
|
1126
|
+
i += 3;
|
|
1127
|
+
} else if (c >= 194 && c < 224) {
|
|
1128
|
+
if (il - i >= 6) {
|
|
1129
|
+
var c2 = parseInt(str.substr(i + 4, 2), 16);
|
|
1130
|
+
newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
|
|
1131
|
+
} else {
|
|
1132
|
+
newStr += str.substr(i, 6);
|
|
1133
|
+
}
|
|
1134
|
+
i += 6;
|
|
1135
|
+
} else if (c >= 224) {
|
|
1136
|
+
if (il - i >= 9) {
|
|
1137
|
+
var _c = parseInt(str.substr(i + 4, 2), 16);
|
|
1138
|
+
var c3 = parseInt(str.substr(i + 7, 2), 16);
|
|
1139
|
+
newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
|
|
1140
|
+
} else {
|
|
1141
|
+
newStr += str.substr(i, 9);
|
|
1142
|
+
}
|
|
1143
|
+
i += 9;
|
|
1144
|
+
} else {
|
|
1145
|
+
newStr += str.substr(i, 3);
|
|
1146
|
+
i += 3;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return newStr;
|
|
1150
|
+
}
|
|
1151
|
+
function _normalizeComponentEncoding(components, protocol) {
|
|
1152
|
+
function decodeUnreserved(str) {
|
|
1153
|
+
var decStr = pctDecChars(str);
|
|
1154
|
+
return !decStr.match(protocol.UNRESERVED) ? str : decStr;
|
|
571
1155
|
}
|
|
1156
|
+
if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
|
|
1157
|
+
if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
1158
|
+
if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
1159
|
+
if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
1160
|
+
if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
1161
|
+
if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
1162
|
+
return components;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function _stripLeadingZeros(str) {
|
|
1166
|
+
return str.replace(/^0*(.*)/, "$1") || "0";
|
|
1167
|
+
}
|
|
1168
|
+
function _normalizeIPv4(host, protocol) {
|
|
1169
|
+
var matches = host.match(protocol.IPV4ADDRESS) || [];
|
|
572
1170
|
|
|
573
|
-
|
|
574
|
-
|
|
1171
|
+
var _matches = slicedToArray(matches, 2),
|
|
1172
|
+
address = _matches[1];
|
|
1173
|
+
|
|
1174
|
+
if (address) {
|
|
1175
|
+
return address.split(".").map(_stripLeadingZeros).join(".");
|
|
1176
|
+
} else {
|
|
1177
|
+
return host;
|
|
575
1178
|
}
|
|
1179
|
+
}
|
|
1180
|
+
function _normalizeIPv6(host, protocol) {
|
|
1181
|
+
var matches = host.match(protocol.IPV6ADDRESS) || [];
|
|
1182
|
+
|
|
1183
|
+
var _matches2 = slicedToArray(matches, 3),
|
|
1184
|
+
address = _matches2[1],
|
|
1185
|
+
zone = _matches2[2];
|
|
1186
|
+
|
|
1187
|
+
if (address) {
|
|
1188
|
+
var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
|
|
1189
|
+
_address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
|
|
1190
|
+
last = _address$toLowerCase$2[0],
|
|
1191
|
+
first = _address$toLowerCase$2[1];
|
|
1192
|
+
|
|
1193
|
+
var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
|
|
1194
|
+
var lastFields = last.split(":").map(_stripLeadingZeros);
|
|
1195
|
+
var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
|
|
1196
|
+
var fieldCount = isLastFieldIPv4Address ? 7 : 8;
|
|
1197
|
+
var lastFieldsStart = lastFields.length - fieldCount;
|
|
1198
|
+
var fields = Array(fieldCount);
|
|
1199
|
+
for (var x = 0; x < fieldCount; ++x) {
|
|
1200
|
+
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
|
|
1201
|
+
}
|
|
1202
|
+
if (isLastFieldIPv4Address) {
|
|
1203
|
+
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
|
|
1204
|
+
}
|
|
1205
|
+
var allZeroFields = fields.reduce(function (acc, field, index) {
|
|
1206
|
+
if (!field || field === "0") {
|
|
1207
|
+
var lastLongest = acc[acc.length - 1];
|
|
1208
|
+
if (lastLongest && lastLongest.index + lastLongest.length === index) {
|
|
1209
|
+
lastLongest.length++;
|
|
1210
|
+
} else {
|
|
1211
|
+
acc.push({ index: index, length: 1 });
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return acc;
|
|
1215
|
+
}, []);
|
|
1216
|
+
var longestZeroFields = allZeroFields.sort(function (a, b) {
|
|
1217
|
+
return b.length - a.length;
|
|
1218
|
+
})[0];
|
|
1219
|
+
var newHost = void 0;
|
|
1220
|
+
if (longestZeroFields && longestZeroFields.length > 1) {
|
|
1221
|
+
var newFirst = fields.slice(0, longestZeroFields.index);
|
|
1222
|
+
var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
|
|
1223
|
+
newHost = newFirst.join(":") + "::" + newLast.join(":");
|
|
1224
|
+
} else {
|
|
1225
|
+
newHost = fields.join(":");
|
|
1226
|
+
}
|
|
1227
|
+
if (zone) {
|
|
1228
|
+
newHost += "%" + zone;
|
|
1229
|
+
}
|
|
1230
|
+
return newHost;
|
|
1231
|
+
} else {
|
|
1232
|
+
return host;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
|
1236
|
+
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
|
|
1237
|
+
function parse(uriString) {
|
|
1238
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1239
|
+
|
|
1240
|
+
var components = {};
|
|
1241
|
+
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
1242
|
+
if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
|
|
1243
|
+
var matches = uriString.match(URI_PARSE);
|
|
1244
|
+
if (matches) {
|
|
1245
|
+
if (NO_MATCH_IS_UNDEFINED) {
|
|
1246
|
+
//store each component
|
|
1247
|
+
components.scheme = matches[1];
|
|
1248
|
+
components.userinfo = matches[3];
|
|
1249
|
+
components.host = matches[4];
|
|
1250
|
+
components.port = parseInt(matches[5], 10);
|
|
1251
|
+
components.path = matches[6] || "";
|
|
1252
|
+
components.query = matches[7];
|
|
1253
|
+
components.fragment = matches[8];
|
|
1254
|
+
//fix port number
|
|
1255
|
+
if (isNaN(components.port)) {
|
|
1256
|
+
components.port = matches[5];
|
|
1257
|
+
}
|
|
1258
|
+
} else {
|
|
1259
|
+
//IE FIX for improper RegExp matching
|
|
1260
|
+
//store each component
|
|
1261
|
+
components.scheme = matches[1] || undefined;
|
|
1262
|
+
components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
|
|
1263
|
+
components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
|
|
1264
|
+
components.port = parseInt(matches[5], 10);
|
|
1265
|
+
components.path = matches[6] || "";
|
|
1266
|
+
components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
|
|
1267
|
+
components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
|
|
1268
|
+
//fix port number
|
|
1269
|
+
if (isNaN(components.port)) {
|
|
1270
|
+
components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
if (components.host) {
|
|
1274
|
+
//normalize IP hosts
|
|
1275
|
+
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
|
|
1276
|
+
}
|
|
1277
|
+
//determine reference type
|
|
1278
|
+
if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
|
|
1279
|
+
components.reference = "same-document";
|
|
1280
|
+
} else if (components.scheme === undefined) {
|
|
1281
|
+
components.reference = "relative";
|
|
1282
|
+
} else if (components.fragment === undefined) {
|
|
1283
|
+
components.reference = "absolute";
|
|
1284
|
+
} else {
|
|
1285
|
+
components.reference = "uri";
|
|
1286
|
+
}
|
|
1287
|
+
//check for reference errors
|
|
1288
|
+
if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
|
|
1289
|
+
components.error = components.error || "URI is not a " + options.reference + " reference.";
|
|
1290
|
+
}
|
|
1291
|
+
//find scheme handler
|
|
1292
|
+
var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
|
1293
|
+
//check if scheme can't handle IRIs
|
|
1294
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
1295
|
+
//if host component is a domain name
|
|
1296
|
+
if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
|
|
1297
|
+
//convert Unicode IDN -> ASCII IDN
|
|
1298
|
+
try {
|
|
1299
|
+
components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
|
|
1300
|
+
} catch (e) {
|
|
1301
|
+
components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
//convert IRI -> URI
|
|
1305
|
+
_normalizeComponentEncoding(components, URI_PROTOCOL);
|
|
1306
|
+
} else {
|
|
1307
|
+
//normalize encodings
|
|
1308
|
+
_normalizeComponentEncoding(components, protocol);
|
|
1309
|
+
}
|
|
1310
|
+
//perform scheme specific parsing
|
|
1311
|
+
if (schemeHandler && schemeHandler.parse) {
|
|
1312
|
+
schemeHandler.parse(components, options);
|
|
1313
|
+
}
|
|
1314
|
+
} else {
|
|
1315
|
+
components.error = components.error || "URI can not be parsed.";
|
|
1316
|
+
}
|
|
1317
|
+
return components;
|
|
1318
|
+
}
|
|
576
1319
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
1320
|
+
function _recomposeAuthority(components, options) {
|
|
1321
|
+
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
1322
|
+
var uriTokens = [];
|
|
1323
|
+
if (components.userinfo !== undefined) {
|
|
1324
|
+
uriTokens.push(components.userinfo);
|
|
1325
|
+
uriTokens.push("@");
|
|
1326
|
+
}
|
|
1327
|
+
if (components.host !== undefined) {
|
|
1328
|
+
//normalize IP hosts, add brackets and escape zone separator for IPv6
|
|
1329
|
+
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
|
|
1330
|
+
return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
|
|
1331
|
+
}));
|
|
1332
|
+
}
|
|
1333
|
+
if (typeof components.port === "number" || typeof components.port === "string") {
|
|
1334
|
+
uriTokens.push(":");
|
|
1335
|
+
uriTokens.push(String(components.port));
|
|
1336
|
+
}
|
|
1337
|
+
return uriTokens.length ? uriTokens.join("") : undefined;
|
|
1338
|
+
}
|
|
580
1339
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
1340
|
+
var RDS1 = /^\.\.?\//;
|
|
1341
|
+
var RDS2 = /^\/\.(\/|$)/;
|
|
1342
|
+
var RDS3 = /^\/\.\.(\/|$)/;
|
|
1343
|
+
var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
|
|
1344
|
+
function removeDotSegments(input) {
|
|
1345
|
+
var output = [];
|
|
1346
|
+
while (input.length) {
|
|
1347
|
+
if (input.match(RDS1)) {
|
|
1348
|
+
input = input.replace(RDS1, "");
|
|
1349
|
+
} else if (input.match(RDS2)) {
|
|
1350
|
+
input = input.replace(RDS2, "/");
|
|
1351
|
+
} else if (input.match(RDS3)) {
|
|
1352
|
+
input = input.replace(RDS3, "/");
|
|
1353
|
+
output.pop();
|
|
1354
|
+
} else if (input === "." || input === "..") {
|
|
1355
|
+
input = "";
|
|
1356
|
+
} else {
|
|
1357
|
+
var im = input.match(RDS5);
|
|
1358
|
+
if (im) {
|
|
1359
|
+
var s = im[0];
|
|
1360
|
+
input = input.slice(s.length);
|
|
1361
|
+
output.push(s);
|
|
1362
|
+
} else {
|
|
1363
|
+
throw new Error("Unexpected dot segment condition");
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return output.join("");
|
|
1368
|
+
}
|
|
584
1369
|
|
|
585
|
-
|
|
586
|
-
|
|
1370
|
+
function serialize(components) {
|
|
1371
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1372
|
+
|
|
1373
|
+
var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
1374
|
+
var uriTokens = [];
|
|
1375
|
+
//find scheme handler
|
|
1376
|
+
var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
|
1377
|
+
//perform scheme specific serialization
|
|
1378
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
|
|
1379
|
+
if (components.host) {
|
|
1380
|
+
//if host component is an IPv6 address
|
|
1381
|
+
if (protocol.IPV6ADDRESS.test(components.host)) ;
|
|
1382
|
+
//TODO: normalize IPv6 address as per RFC 5952
|
|
1383
|
+
|
|
1384
|
+
//if host component is a domain name
|
|
1385
|
+
else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
|
|
1386
|
+
//convert IDN via punycode
|
|
1387
|
+
try {
|
|
1388
|
+
components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
|
|
1389
|
+
} catch (e) {
|
|
1390
|
+
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
//normalize encoding
|
|
1395
|
+
_normalizeComponentEncoding(components, protocol);
|
|
1396
|
+
if (options.reference !== "suffix" && components.scheme) {
|
|
1397
|
+
uriTokens.push(components.scheme);
|
|
1398
|
+
uriTokens.push(":");
|
|
1399
|
+
}
|
|
1400
|
+
var authority = _recomposeAuthority(components, options);
|
|
1401
|
+
if (authority !== undefined) {
|
|
1402
|
+
if (options.reference !== "suffix") {
|
|
1403
|
+
uriTokens.push("//");
|
|
1404
|
+
}
|
|
1405
|
+
uriTokens.push(authority);
|
|
1406
|
+
if (components.path && components.path.charAt(0) !== "/") {
|
|
1407
|
+
uriTokens.push("/");
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
if (components.path !== undefined) {
|
|
1411
|
+
var s = components.path;
|
|
1412
|
+
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
1413
|
+
s = removeDotSegments(s);
|
|
1414
|
+
}
|
|
1415
|
+
if (authority === undefined) {
|
|
1416
|
+
s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
|
|
1417
|
+
}
|
|
1418
|
+
uriTokens.push(s);
|
|
1419
|
+
}
|
|
1420
|
+
if (components.query !== undefined) {
|
|
1421
|
+
uriTokens.push("?");
|
|
1422
|
+
uriTokens.push(components.query);
|
|
1423
|
+
}
|
|
1424
|
+
if (components.fragment !== undefined) {
|
|
1425
|
+
uriTokens.push("#");
|
|
1426
|
+
uriTokens.push(components.fragment);
|
|
1427
|
+
}
|
|
1428
|
+
return uriTokens.join(""); //merge tokens into a string
|
|
1429
|
+
}
|
|
587
1430
|
|
|
588
|
-
|
|
1431
|
+
function resolveComponents(base, relative) {
|
|
1432
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1433
|
+
var skipNormalization = arguments[3];
|
|
589
1434
|
|
|
590
|
-
|
|
591
|
-
|
|
1435
|
+
var target = {};
|
|
1436
|
+
if (!skipNormalization) {
|
|
1437
|
+
base = parse(serialize(base, options), options); //normalize base components
|
|
1438
|
+
relative = parse(serialize(relative, options), options); //normalize relative components
|
|
1439
|
+
}
|
|
1440
|
+
options = options || {};
|
|
1441
|
+
if (!options.tolerant && relative.scheme) {
|
|
1442
|
+
target.scheme = relative.scheme;
|
|
1443
|
+
//target.authority = relative.authority;
|
|
1444
|
+
target.userinfo = relative.userinfo;
|
|
1445
|
+
target.host = relative.host;
|
|
1446
|
+
target.port = relative.port;
|
|
1447
|
+
target.path = removeDotSegments(relative.path || "");
|
|
1448
|
+
target.query = relative.query;
|
|
592
1449
|
} else {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
1450
|
+
if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
|
|
1451
|
+
//target.authority = relative.authority;
|
|
1452
|
+
target.userinfo = relative.userinfo;
|
|
1453
|
+
target.host = relative.host;
|
|
1454
|
+
target.port = relative.port;
|
|
1455
|
+
target.path = removeDotSegments(relative.path || "");
|
|
1456
|
+
target.query = relative.query;
|
|
1457
|
+
} else {
|
|
1458
|
+
if (!relative.path) {
|
|
1459
|
+
target.path = base.path;
|
|
1460
|
+
if (relative.query !== undefined) {
|
|
1461
|
+
target.query = relative.query;
|
|
1462
|
+
} else {
|
|
1463
|
+
target.query = base.query;
|
|
1464
|
+
}
|
|
1465
|
+
} else {
|
|
1466
|
+
if (relative.path.charAt(0) === "/") {
|
|
1467
|
+
target.path = removeDotSegments(relative.path);
|
|
1468
|
+
} else {
|
|
1469
|
+
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
|
|
1470
|
+
target.path = "/" + relative.path;
|
|
1471
|
+
} else if (!base.path) {
|
|
1472
|
+
target.path = relative.path;
|
|
1473
|
+
} else {
|
|
1474
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
1475
|
+
}
|
|
1476
|
+
target.path = removeDotSegments(target.path);
|
|
1477
|
+
}
|
|
1478
|
+
target.query = relative.query;
|
|
1479
|
+
}
|
|
1480
|
+
//target.authority = base.authority;
|
|
1481
|
+
target.userinfo = base.userinfo;
|
|
1482
|
+
target.host = base.host;
|
|
1483
|
+
target.port = base.port;
|
|
1484
|
+
}
|
|
1485
|
+
target.scheme = base.scheme;
|
|
596
1486
|
}
|
|
1487
|
+
target.fragment = relative.fragment;
|
|
1488
|
+
return target;
|
|
1489
|
+
}
|
|
597
1490
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
1491
|
+
function resolve(baseURI, relativeURI, options) {
|
|
1492
|
+
var schemelessOptions = assign({ scheme: 'null' }, options);
|
|
1493
|
+
return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function normalize(uri, options) {
|
|
1497
|
+
if (typeof uri === "string") {
|
|
1498
|
+
uri = serialize(parse(uri, options), options);
|
|
1499
|
+
} else if (typeOf(uri) === "object") {
|
|
1500
|
+
uri = parse(serialize(uri, options), options);
|
|
603
1501
|
}
|
|
1502
|
+
return uri;
|
|
1503
|
+
}
|
|
604
1504
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
return _addSlash(host);
|
|
1505
|
+
function equal(uriA, uriB, options) {
|
|
1506
|
+
if (typeof uriA === "string") {
|
|
1507
|
+
uriA = serialize(parse(uriA, options), options);
|
|
1508
|
+
} else if (typeOf(uriA) === "object") {
|
|
1509
|
+
uriA = serialize(uriA, options);
|
|
611
1510
|
}
|
|
612
|
-
|
|
613
|
-
|
|
1511
|
+
if (typeof uriB === "string") {
|
|
1512
|
+
uriB = serialize(parse(uriB, options), options);
|
|
1513
|
+
} else if (typeOf(uriB) === "object") {
|
|
1514
|
+
uriB = serialize(uriB, options);
|
|
1515
|
+
}
|
|
1516
|
+
return uriA === uriB;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
function escapeComponent(str, options) {
|
|
1520
|
+
return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
function unescapeComponent(str, options) {
|
|
1524
|
+
return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
var handler = {
|
|
1528
|
+
scheme: "http",
|
|
1529
|
+
domainHost: true,
|
|
1530
|
+
parse: function parse(components, options) {
|
|
1531
|
+
//report missing host
|
|
1532
|
+
if (!components.host) {
|
|
1533
|
+
components.error = components.error || "HTTP URIs must have a host.";
|
|
1534
|
+
}
|
|
1535
|
+
return components;
|
|
1536
|
+
},
|
|
1537
|
+
serialize: function serialize(components, options) {
|
|
1538
|
+
var secure = String(components.scheme).toLowerCase() === "https";
|
|
1539
|
+
//normalize the default port
|
|
1540
|
+
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
1541
|
+
components.port = undefined;
|
|
1542
|
+
}
|
|
1543
|
+
//normalize the empty path
|
|
1544
|
+
if (!components.path) {
|
|
1545
|
+
components.path = "/";
|
|
1546
|
+
}
|
|
1547
|
+
//NOTE: We do not parse query strings for HTTP URIs
|
|
1548
|
+
//as WWW Form Url Encoded query strings are part of the HTML4+ spec,
|
|
1549
|
+
//and not the HTTP spec.
|
|
1550
|
+
return components;
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
var handler$1 = {
|
|
1555
|
+
scheme: "https",
|
|
1556
|
+
domainHost: handler.domainHost,
|
|
1557
|
+
parse: handler.parse,
|
|
1558
|
+
serialize: handler.serialize
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
function isSecure(wsComponents) {
|
|
1562
|
+
return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
|
|
614
1563
|
}
|
|
1564
|
+
//RFC 6455
|
|
1565
|
+
var handler$2 = {
|
|
1566
|
+
scheme: "ws",
|
|
1567
|
+
domainHost: true,
|
|
1568
|
+
parse: function parse(components, options) {
|
|
1569
|
+
var wsComponents = components;
|
|
1570
|
+
//indicate if the secure flag is set
|
|
1571
|
+
wsComponents.secure = isSecure(wsComponents);
|
|
1572
|
+
//construct resouce name
|
|
1573
|
+
wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '');
|
|
1574
|
+
wsComponents.path = undefined;
|
|
1575
|
+
wsComponents.query = undefined;
|
|
1576
|
+
return wsComponents;
|
|
1577
|
+
},
|
|
1578
|
+
serialize: function serialize(wsComponents, options) {
|
|
1579
|
+
//normalize the default port
|
|
1580
|
+
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
1581
|
+
wsComponents.port = undefined;
|
|
1582
|
+
}
|
|
1583
|
+
//ensure scheme matches secure flag
|
|
1584
|
+
if (typeof wsComponents.secure === 'boolean') {
|
|
1585
|
+
wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws';
|
|
1586
|
+
wsComponents.secure = undefined;
|
|
1587
|
+
}
|
|
1588
|
+
//reconstruct path from resource name
|
|
1589
|
+
if (wsComponents.resourceName) {
|
|
1590
|
+
var _wsComponents$resourc = wsComponents.resourceName.split('?'),
|
|
1591
|
+
_wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
|
|
1592
|
+
path = _wsComponents$resourc2[0],
|
|
1593
|
+
query = _wsComponents$resourc2[1];
|
|
1594
|
+
|
|
1595
|
+
wsComponents.path = path && path !== '/' ? path : undefined;
|
|
1596
|
+
wsComponents.query = query;
|
|
1597
|
+
wsComponents.resourceName = undefined;
|
|
1598
|
+
}
|
|
1599
|
+
//forbid fragment component
|
|
1600
|
+
wsComponents.fragment = undefined;
|
|
1601
|
+
return wsComponents;
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
var handler$3 = {
|
|
1606
|
+
scheme: "wss",
|
|
1607
|
+
domainHost: handler$2.domainHost,
|
|
1608
|
+
parse: handler$2.parse,
|
|
1609
|
+
serialize: handler$2.serialize
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
var O = {};
|
|
1613
|
+
//RFC 3986
|
|
1614
|
+
var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + ("\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" ) + "]";
|
|
1615
|
+
var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
|
|
1616
|
+
var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
|
|
1617
|
+
//RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
|
|
1618
|
+
//const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
|
|
1619
|
+
//const WSP$$ = "[\\x20\\x09]";
|
|
1620
|
+
//const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
|
|
1621
|
+
//const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
|
|
1622
|
+
//const VCHAR$$ = "[\\x21-\\x7E]";
|
|
1623
|
+
//const WSP$$ = "[\\x20\\x09]";
|
|
1624
|
+
//const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
|
|
1625
|
+
//const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
|
|
1626
|
+
//const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
|
|
1627
|
+
//const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
|
|
1628
|
+
var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
|
|
1629
|
+
var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
|
|
1630
|
+
var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
|
|
1631
|
+
var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
|
|
1632
|
+
var UNRESERVED = new RegExp(UNRESERVED$$, "g");
|
|
1633
|
+
var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
|
|
1634
|
+
var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
|
|
1635
|
+
var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
|
|
1636
|
+
var NOT_HFVALUE = NOT_HFNAME;
|
|
1637
|
+
function decodeUnreserved(str) {
|
|
1638
|
+
var decStr = pctDecChars(str);
|
|
1639
|
+
return !decStr.match(UNRESERVED) ? str : decStr;
|
|
1640
|
+
}
|
|
1641
|
+
var handler$4 = {
|
|
1642
|
+
scheme: "mailto",
|
|
1643
|
+
parse: function parse$$1(components, options) {
|
|
1644
|
+
var mailtoComponents = components;
|
|
1645
|
+
var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
|
|
1646
|
+
mailtoComponents.path = undefined;
|
|
1647
|
+
if (mailtoComponents.query) {
|
|
1648
|
+
var unknownHeaders = false;
|
|
1649
|
+
var headers = {};
|
|
1650
|
+
var hfields = mailtoComponents.query.split("&");
|
|
1651
|
+
for (var x = 0, xl = hfields.length; x < xl; ++x) {
|
|
1652
|
+
var hfield = hfields[x].split("=");
|
|
1653
|
+
switch (hfield[0]) {
|
|
1654
|
+
case "to":
|
|
1655
|
+
var toAddrs = hfield[1].split(",");
|
|
1656
|
+
for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
|
|
1657
|
+
to.push(toAddrs[_x]);
|
|
1658
|
+
}
|
|
1659
|
+
break;
|
|
1660
|
+
case "subject":
|
|
1661
|
+
mailtoComponents.subject = unescapeComponent(hfield[1], options);
|
|
1662
|
+
break;
|
|
1663
|
+
case "body":
|
|
1664
|
+
mailtoComponents.body = unescapeComponent(hfield[1], options);
|
|
1665
|
+
break;
|
|
1666
|
+
default:
|
|
1667
|
+
unknownHeaders = true;
|
|
1668
|
+
headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
|
|
1669
|
+
break;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
if (unknownHeaders) mailtoComponents.headers = headers;
|
|
1673
|
+
}
|
|
1674
|
+
mailtoComponents.query = undefined;
|
|
1675
|
+
for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
|
|
1676
|
+
var addr = to[_x2].split("@");
|
|
1677
|
+
addr[0] = unescapeComponent(addr[0]);
|
|
1678
|
+
if (!options.unicodeSupport) {
|
|
1679
|
+
//convert Unicode IDN -> ASCII IDN
|
|
1680
|
+
try {
|
|
1681
|
+
addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
|
|
1682
|
+
} catch (e) {
|
|
1683
|
+
mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
|
|
1684
|
+
}
|
|
1685
|
+
} else {
|
|
1686
|
+
addr[1] = unescapeComponent(addr[1], options).toLowerCase();
|
|
1687
|
+
}
|
|
1688
|
+
to[_x2] = addr.join("@");
|
|
1689
|
+
}
|
|
1690
|
+
return mailtoComponents;
|
|
1691
|
+
},
|
|
1692
|
+
serialize: function serialize$$1(mailtoComponents, options) {
|
|
1693
|
+
var components = mailtoComponents;
|
|
1694
|
+
var to = toArray(mailtoComponents.to);
|
|
1695
|
+
if (to) {
|
|
1696
|
+
for (var x = 0, xl = to.length; x < xl; ++x) {
|
|
1697
|
+
var toAddr = String(to[x]);
|
|
1698
|
+
var atIdx = toAddr.lastIndexOf("@");
|
|
1699
|
+
var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
|
|
1700
|
+
var domain = toAddr.slice(atIdx + 1);
|
|
1701
|
+
//convert IDN via punycode
|
|
1702
|
+
try {
|
|
1703
|
+
domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
|
|
1704
|
+
} catch (e) {
|
|
1705
|
+
components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
|
|
1706
|
+
}
|
|
1707
|
+
to[x] = localPart + "@" + domain;
|
|
1708
|
+
}
|
|
1709
|
+
components.path = to.join(",");
|
|
1710
|
+
}
|
|
1711
|
+
var headers = mailtoComponents.headers = mailtoComponents.headers || {};
|
|
1712
|
+
if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
|
|
1713
|
+
if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
|
|
1714
|
+
var fields = [];
|
|
1715
|
+
for (var name in headers) {
|
|
1716
|
+
if (headers[name] !== O[name]) {
|
|
1717
|
+
fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
if (fields.length) {
|
|
1721
|
+
components.query = fields.join("&");
|
|
1722
|
+
}
|
|
1723
|
+
return components;
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
var URN_PARSE = /^([^\:]+)\:(.*)/;
|
|
1728
|
+
//RFC 2141
|
|
1729
|
+
var handler$5 = {
|
|
1730
|
+
scheme: "urn",
|
|
1731
|
+
parse: function parse$$1(components, options) {
|
|
1732
|
+
var matches = components.path && components.path.match(URN_PARSE);
|
|
1733
|
+
var urnComponents = components;
|
|
1734
|
+
if (matches) {
|
|
1735
|
+
var scheme = options.scheme || urnComponents.scheme || "urn";
|
|
1736
|
+
var nid = matches[1].toLowerCase();
|
|
1737
|
+
var nss = matches[2];
|
|
1738
|
+
var urnScheme = scheme + ":" + (options.nid || nid);
|
|
1739
|
+
var schemeHandler = SCHEMES[urnScheme];
|
|
1740
|
+
urnComponents.nid = nid;
|
|
1741
|
+
urnComponents.nss = nss;
|
|
1742
|
+
urnComponents.path = undefined;
|
|
1743
|
+
if (schemeHandler) {
|
|
1744
|
+
urnComponents = schemeHandler.parse(urnComponents, options);
|
|
1745
|
+
}
|
|
1746
|
+
} else {
|
|
1747
|
+
urnComponents.error = urnComponents.error || "URN can not be parsed.";
|
|
1748
|
+
}
|
|
1749
|
+
return urnComponents;
|
|
1750
|
+
},
|
|
1751
|
+
serialize: function serialize$$1(urnComponents, options) {
|
|
1752
|
+
var scheme = options.scheme || urnComponents.scheme || "urn";
|
|
1753
|
+
var nid = urnComponents.nid;
|
|
1754
|
+
var urnScheme = scheme + ":" + (options.nid || nid);
|
|
1755
|
+
var schemeHandler = SCHEMES[urnScheme];
|
|
1756
|
+
if (schemeHandler) {
|
|
1757
|
+
urnComponents = schemeHandler.serialize(urnComponents, options);
|
|
1758
|
+
}
|
|
1759
|
+
var uriComponents = urnComponents;
|
|
1760
|
+
var nss = urnComponents.nss;
|
|
1761
|
+
uriComponents.path = (nid || options.nid) + ":" + nss;
|
|
1762
|
+
return uriComponents;
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
1767
|
+
//RFC 4122
|
|
1768
|
+
var handler$6 = {
|
|
1769
|
+
scheme: "urn:uuid",
|
|
1770
|
+
parse: function parse(urnComponents, options) {
|
|
1771
|
+
var uuidComponents = urnComponents;
|
|
1772
|
+
uuidComponents.uuid = uuidComponents.nss;
|
|
1773
|
+
uuidComponents.nss = undefined;
|
|
1774
|
+
if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
|
|
1775
|
+
uuidComponents.error = uuidComponents.error || "UUID is not valid.";
|
|
1776
|
+
}
|
|
1777
|
+
return uuidComponents;
|
|
1778
|
+
},
|
|
1779
|
+
serialize: function serialize(uuidComponents, options) {
|
|
1780
|
+
var urnComponents = uuidComponents;
|
|
1781
|
+
//normalize UUID
|
|
1782
|
+
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
1783
|
+
return urnComponents;
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
SCHEMES[handler.scheme] = handler;
|
|
1788
|
+
SCHEMES[handler$1.scheme] = handler$1;
|
|
1789
|
+
SCHEMES[handler$2.scheme] = handler$2;
|
|
1790
|
+
SCHEMES[handler$3.scheme] = handler$3;
|
|
1791
|
+
SCHEMES[handler$4.scheme] = handler$4;
|
|
1792
|
+
SCHEMES[handler$5.scheme] = handler$5;
|
|
1793
|
+
SCHEMES[handler$6.scheme] = handler$6;
|
|
1794
|
+
|
|
1795
|
+
exports.SCHEMES = SCHEMES;
|
|
1796
|
+
exports.pctEncChar = pctEncChar;
|
|
1797
|
+
exports.pctDecChars = pctDecChars;
|
|
1798
|
+
exports.parse = parse;
|
|
1799
|
+
exports.removeDotSegments = removeDotSegments;
|
|
1800
|
+
exports.serialize = serialize;
|
|
1801
|
+
exports.resolveComponents = resolveComponents;
|
|
1802
|
+
exports.resolve = resolve;
|
|
1803
|
+
exports.normalize = normalize;
|
|
1804
|
+
exports.equal = equal;
|
|
1805
|
+
exports.escapeComponent = escapeComponent;
|
|
1806
|
+
exports.unescapeComponent = unescapeComponent;
|
|
1807
|
+
|
|
1808
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1809
|
+
|
|
1810
|
+
})));
|
|
1811
|
+
|
|
1812
|
+
});
|
|
1813
|
+
|
|
1814
|
+
unwrapExports(uri_all);
|
|
615
1815
|
|
|
616
1816
|
const isObject$1 = (value) => typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
617
1817
|
const isType = {
|
|
@@ -625,29 +1825,17 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
625
1825
|
};
|
|
626
1826
|
const jsonTypeOf$2 = (value, type) => isType[type](value);
|
|
627
1827
|
|
|
628
|
-
const
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
const urlFragment = url.slice(ndx + 1);
|
|
633
|
-
|
|
634
|
-
return [decodeURI(urlReference), decodeURI(urlFragment)];
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
const getScheme = (url) => {
|
|
638
|
-
const matches = RegExp(/^(.+):\/\//).exec(url);
|
|
639
|
-
return matches ? matches[1] : "";
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
const safeResolveUrl$1 = (contextUrl, url) => {
|
|
643
|
-
const resolvedUrl = urlResolveBrowser(contextUrl, url);
|
|
644
|
-
const contextId = splitUrl$4(contextUrl)[0];
|
|
645
|
-
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") {
|
|
1828
|
+
const resolveUrl$3 = (contextUrl, url) => {
|
|
1829
|
+
const resolvedUrl = uri_all.resolve(contextUrl, url, { iri: true });
|
|
1830
|
+
const contextId = uri_all.resolve(contextUrl, "", { iri: true });
|
|
1831
|
+
if (contextId && uri_all.parse(resolvedUrl).scheme === "file" && uri_all.parse(contextUrl).scheme !== "file") {
|
|
646
1832
|
throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`);
|
|
647
1833
|
}
|
|
648
1834
|
return resolvedUrl;
|
|
649
1835
|
};
|
|
650
1836
|
|
|
1837
|
+
const urlFragment$1 = (uri) => uri_all.unescapeComponent(uri_all.parse(uri).fragment) || "";
|
|
1838
|
+
|
|
651
1839
|
const CHAR_BACKWARD_SLASH = 47;
|
|
652
1840
|
|
|
653
1841
|
const pathRelative$1 = (from, to) => {
|
|
@@ -711,7 +1899,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
711
1899
|
return to.slice(toStart, to.length);
|
|
712
1900
|
};
|
|
713
1901
|
|
|
714
|
-
var common$1 = { jsonTypeOf: jsonTypeOf$2,
|
|
1902
|
+
var common$1 = { jsonTypeOf: jsonTypeOf$2, resolveUrl: resolveUrl$3, urlFragment: urlFragment$1, pathRelative: pathRelative$1 };
|
|
715
1903
|
|
|
716
1904
|
const nil$2 = "";
|
|
717
1905
|
|
|
@@ -869,12 +2057,12 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
869
2057
|
reference.href;
|
|
870
2058
|
reference.value;
|
|
871
2059
|
|
|
872
|
-
const { jsonTypeOf: jsonTypeOf$1 } = common$1;
|
|
2060
|
+
const { resolveUrl: resolveUrl$2, jsonTypeOf: jsonTypeOf$1 } = common$1;
|
|
873
2061
|
|
|
874
2062
|
|
|
875
2063
|
|
|
876
2064
|
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined });
|
|
877
|
-
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance });
|
|
2065
|
+
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id: resolveUrl$2(id, ""), instance, value: instance });
|
|
878
2066
|
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`;
|
|
879
2067
|
const value$1 = (doc) => reference.isReference(doc.value) ? reference.value(doc.value) : doc.value;
|
|
880
2068
|
const has$1 = (key, doc) => key in value$1(doc);
|
|
@@ -1217,7 +2405,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1217
2405
|
|
|
1218
2406
|
var fetch_browser = fetch;
|
|
1219
2407
|
|
|
1220
|
-
const { jsonTypeOf,
|
|
2408
|
+
const { jsonTypeOf, resolveUrl: resolveUrl$1, urlFragment, pathRelative } = common$1;
|
|
1221
2409
|
|
|
1222
2410
|
|
|
1223
2411
|
|
|
@@ -1248,7 +2436,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1248
2436
|
schema = JSON.parse(JSON.stringify(schema));
|
|
1249
2437
|
|
|
1250
2438
|
// Schema Version
|
|
1251
|
-
const schemaVersion =
|
|
2439
|
+
const schemaVersion = resolveUrl$1(schema["$schema"] || defaultSchemaVersion, "");
|
|
1252
2440
|
if (!schemaVersion) {
|
|
1253
2441
|
throw Error("Couldn't determine schema version");
|
|
1254
2442
|
}
|
|
@@ -1257,12 +2445,13 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1257
2445
|
// Identifier
|
|
1258
2446
|
const baseToken = getConfig(schemaVersion, "baseToken");
|
|
1259
2447
|
const anchorToken = getConfig(schemaVersion, "anchorToken");
|
|
1260
|
-
const externalId =
|
|
1261
|
-
if (!externalId && !
|
|
2448
|
+
const externalId = resolveUrl$1(url, "");
|
|
2449
|
+
if (!externalId && !resolveUrl$1(schema[baseToken] || "", "")) {
|
|
1262
2450
|
throw Error("Couldn't determine an identifier for the schema");
|
|
1263
2451
|
}
|
|
1264
|
-
const internalUrl =
|
|
1265
|
-
const
|
|
2452
|
+
const internalUrl = resolveUrl$1(externalId, schema[baseToken] || "");
|
|
2453
|
+
const id = resolveUrl$1(internalUrl, "");
|
|
2454
|
+
const fragment = urlFragment(internalUrl);
|
|
1266
2455
|
delete schema[baseToken];
|
|
1267
2456
|
if (fragment && baseToken === anchorToken) {
|
|
1268
2457
|
schema[anchorToken] = anchorToken !== baseToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`;
|
|
@@ -1309,11 +2498,11 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1309
2498
|
|
|
1310
2499
|
const processSchema = (subject, id, schemaVersion, pointer, anchors, dynamicAnchors) => {
|
|
1311
2500
|
if (jsonTypeOf(subject, "object")) {
|
|
1312
|
-
const embeddedSchemaVersion = typeof subject["$schema"] === "string" ?
|
|
2501
|
+
const embeddedSchemaVersion = typeof subject["$schema"] === "string" ? resolveUrl$1(subject["$schema"], "") : schemaVersion;
|
|
1313
2502
|
const embeddedEmbeddedToken = getConfig(embeddedSchemaVersion, "embeddedToken");
|
|
1314
2503
|
const embeddedAnchorToken = getConfig(embeddedSchemaVersion, "anchorToken");
|
|
1315
2504
|
if (typeof subject[embeddedEmbeddedToken] === "string" && (embeddedEmbeddedToken !== embeddedAnchorToken || subject[embeddedEmbeddedToken][0] !== "#")) {
|
|
1316
|
-
const ref =
|
|
2505
|
+
const ref = resolveUrl$1(id, subject[embeddedEmbeddedToken]);
|
|
1317
2506
|
subject[embeddedEmbeddedToken] = ref;
|
|
1318
2507
|
add$1(subject, ref, schemaVersion);
|
|
1319
2508
|
return reference.cons(subject[embeddedEmbeddedToken], subject);
|
|
@@ -1372,8 +2561,9 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1372
2561
|
});
|
|
1373
2562
|
|
|
1374
2563
|
const get = async (url, contextDoc = nil) => {
|
|
1375
|
-
const resolvedUrl =
|
|
1376
|
-
const
|
|
2564
|
+
const resolvedUrl = resolveUrl$1(uri(contextDoc), url);
|
|
2565
|
+
const id = resolveUrl$1(resolvedUrl, "");
|
|
2566
|
+
const fragment = urlFragment(resolvedUrl);
|
|
1377
2567
|
|
|
1378
2568
|
if (!hasStoredSchema(id)) {
|
|
1379
2569
|
const response = await fetch_browser(id, { headers: { Accept: "application/schema+json" } });
|
|
@@ -1473,7 +2663,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1473
2663
|
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken");
|
|
1474
2664
|
Object.entries(schemaDoc.dynamicAnchors)
|
|
1475
2665
|
.forEach(([anchor, uri]) => {
|
|
1476
|
-
const pointer =
|
|
2666
|
+
const pointer = urlFragment(uri);
|
|
1477
2667
|
lib$3.assign(pointer, schema, {
|
|
1478
2668
|
[dynamicAnchorToken]: anchor,
|
|
1479
2669
|
...lib$3.get(pointer, schema)
|
|
@@ -1542,7 +2732,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1542
2732
|
|
|
1543
2733
|
var invalidSchemaError = InvalidSchemaError$1;
|
|
1544
2734
|
|
|
1545
|
-
const {
|
|
2735
|
+
const { resolveUrl } = common$1;
|
|
1546
2736
|
|
|
1547
2737
|
|
|
1548
2738
|
|
|
@@ -1701,7 +2891,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
1701
2891
|
|
|
1702
2892
|
const interpretSchema = (schemaUri, instance, ast, dynamicAnchors) => {
|
|
1703
2893
|
const keywordId = getKeywordId(schemaUri, ast);
|
|
1704
|
-
const id =
|
|
2894
|
+
const id = resolveUrl(schemaUri, "");
|
|
1705
2895
|
return getKeyword(keywordId).interpret(schemaUri, instance, ast, { ...ast.metaData[id].dynamicAnchors, ...dynamicAnchors });
|
|
1706
2896
|
};
|
|
1707
2897
|
|