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