@oozcitak/url 3.0.0 → 4.0.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.
@@ -1,50 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setValidationErrorCallback = setValidationErrorCallback;
4
- exports.newURL = newURL;
5
- exports.isSpecialScheme = isSpecialScheme;
6
- exports.isSpecial = isSpecial;
7
- exports.defaultPort = defaultPort;
8
- exports.includesCredentials = includesCredentials;
9
- exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;
10
- exports.urlSerializer = urlSerializer;
11
- exports.hostSerializer = hostSerializer;
12
- exports.iPv4Serializer = iPv4Serializer;
13
- exports.iPv6Serializer = iPv6Serializer;
14
- exports.urlParser = urlParser;
15
- exports.basicURLParser = basicURLParser;
16
- exports.setTheUsername = setTheUsername;
17
- exports.setThePassword = setThePassword;
18
- exports.isSingleDotPathSegment = isSingleDotPathSegment;
19
- exports.isDoubleDotPathSegment = isDoubleDotPathSegment;
20
- exports.shorten = shorten;
21
- exports.isNormalizedWindowsDriveLetter = isNormalizedWindowsDriveLetter;
22
- exports.isWindowsDriveLetter = isWindowsDriveLetter;
23
- exports.startsWithAWindowsDriveLetter = startsWithAWindowsDriveLetter;
24
- exports.hostParser = hostParser;
25
- exports.iPv4NumberParser = iPv4NumberParser;
26
- exports.iPv4Parser = iPv4Parser;
27
- exports.iPv6Parser = iPv6Parser;
28
- exports.opaqueHostParser = opaqueHostParser;
29
- exports.resolveABlobURL = resolveABlobURL;
30
- exports.percentEncode = percentEncode;
31
- exports.percentDecode = percentDecode;
32
- exports.stringPercentDecode = stringPercentDecode;
33
- exports.utf8PercentEncode = utf8PercentEncode;
34
- exports.hostEquals = hostEquals;
35
- exports.urlEquals = urlEquals;
36
- exports.urlEncodedStringParser = urlEncodedStringParser;
37
- exports.urlEncodedParser = urlEncodedParser;
38
- exports.urlEncodedByteSerializer = urlEncodedByteSerializer;
39
- exports.urlEncodedSerializer = urlEncodedSerializer;
40
- exports.origin = origin;
41
- exports.domainToASCII = domainToASCII;
42
- exports.domainToUnicode = domainToUnicode;
43
- exports.asciiSerializationOfAnOrigin = asciiSerializationOfAnOrigin;
44
- const util_1 = require("@oozcitak/util");
45
- const interfaces_1 = require("./interfaces");
46
- const infra_1 = require("@oozcitak/infra");
47
- const url_1 = require("url");
1
+ import { isNumber, isArray, utf8Decode, utf8Encode, StringWalker } from "@oozcitak/util";
2
+ import { ParserState, OpaqueOrigin } from "./interfaces";
3
+ import { codePoint as infraCodePoint, list as infraList, byteSequence as infraByteSequence } from "@oozcitak/infra";
4
+ import { domainToASCII as nodeDomainToASCII, domainToUnicode as nodeDomainToUnicode } from "url";
48
5
  let _validationErrorCallback;
49
6
  /**
50
7
  * Default ports for a special URL scheme.
@@ -99,7 +56,7 @@ const _forbiddenHostCodePoint = /[\0\t\f\r #%/:?@\[\\\]]/;
99
56
  * @param validationErrorCallback - a callback function to be called when a
100
57
  * validation error occurs
101
58
  */
102
- function setValidationErrorCallback(validationErrorCallback) {
59
+ export function setValidationErrorCallback(validationErrorCallback) {
103
60
  _validationErrorCallback = validationErrorCallback;
104
61
  }
105
62
  /**
@@ -115,7 +72,7 @@ function validationError(message) {
115
72
  /**
116
73
  * Creates a new URL.
117
74
  */
118
- function newURL() {
75
+ export function newURL() {
119
76
  return {
120
77
  scheme: '',
121
78
  username: '',
@@ -134,7 +91,7 @@ function newURL() {
134
91
  *
135
92
  * @param scheme - a scheme
136
93
  */
137
- function isSpecialScheme(scheme) {
94
+ export function isSpecialScheme(scheme) {
138
95
  return (scheme in _defaultPorts);
139
96
  }
140
97
  /**
@@ -142,7 +99,7 @@ function isSpecialScheme(scheme) {
142
99
  *
143
100
  * @param url - an URL
144
101
  */
145
- function isSpecial(url) {
102
+ export function isSpecial(url) {
146
103
  return isSpecialScheme(url.scheme);
147
104
  }
148
105
  /**
@@ -150,7 +107,7 @@ function isSpecial(url) {
150
107
  *
151
108
  * @param scheme - a scheme
152
109
  */
153
- function defaultPort(scheme) {
110
+ export function defaultPort(scheme) {
154
111
  return _defaultPorts[scheme] || null;
155
112
  }
156
113
  /**
@@ -158,7 +115,7 @@ function defaultPort(scheme) {
158
115
  *
159
116
  * @param url - an URL
160
117
  */
161
- function includesCredentials(url) {
118
+ export function includesCredentials(url) {
162
119
  return url.username !== '' || url.password !== '';
163
120
  }
164
121
  /**
@@ -166,7 +123,7 @@ function includesCredentials(url) {
166
123
  *
167
124
  * @param url - an URL
168
125
  */
169
- function cannotHaveAUsernamePasswordPort(url) {
126
+ export function cannotHaveAUsernamePasswordPort(url) {
170
127
  /**
171
128
  * A URL cannot have a username/password/port if its host is null or the
172
129
  * empty string, its cannot-be-a-base-URL flag is set, or its scheme is
@@ -180,7 +137,7 @@ function cannotHaveAUsernamePasswordPort(url) {
180
137
  *
181
138
  * @param url - an URL
182
139
  */
183
- function urlSerializer(url, excludeFragmentFlag = false) {
140
+ export function urlSerializer(url, excludeFragmentFlag = false) {
184
141
  /**
185
142
  * 1. Let output be url’s scheme and U+003A (:) concatenated.
186
143
  */
@@ -259,7 +216,7 @@ function urlSerializer(url, excludeFragmentFlag = false) {
259
216
  *
260
217
  * @param host - a host
261
218
  */
262
- function hostSerializer(host) {
219
+ export function hostSerializer(host) {
263
220
  /**
264
221
  * 1. If host is an IPv4 address, return the result of running the IPv4
265
222
  * serializer on host.
@@ -268,10 +225,10 @@ function hostSerializer(host) {
268
225
  * U+005D (]).
269
226
  * 3. Otherwise, host is a domain, opaque host, or empty host, return host.
270
227
  */
271
- if ((0, util_1.isNumber)(host)) {
228
+ if (isNumber(host)) {
272
229
  return iPv4Serializer(host);
273
230
  }
274
- else if ((0, util_1.isArray)(host)) {
231
+ else if (isArray(host)) {
275
232
  return '[' + iPv6Serializer(host) + ']';
276
233
  }
277
234
  else {
@@ -283,7 +240,7 @@ function hostSerializer(host) {
283
240
  *
284
241
  * @param address - an IPv4 address
285
242
  */
286
- function iPv4Serializer(address) {
243
+ export function iPv4Serializer(address) {
287
244
  /**
288
245
  * 1. Let output be the empty string.
289
246
  * 2. Let n be the value of address.
@@ -309,7 +266,7 @@ function iPv4Serializer(address) {
309
266
  *
310
267
  * @param address - an IPv6 address represented as a list of eight numbers
311
268
  */
312
- function iPv6Serializer(address) {
269
+ export function iPv6Serializer(address) {
313
270
  /**
314
271
  * 1. Let output be the empty string.
315
272
  * 2. Let compress be an index to the first IPv6 piece in the first longest
@@ -386,7 +343,7 @@ function iPv6Serializer(address) {
386
343
  * @param baseURL - base URL
387
344
  * @param encodingOverride - encoding override
388
345
  */
389
- function urlParser(input, baseURL, encodingOverride) {
346
+ export function urlParser(input, baseURL, encodingOverride) {
390
347
  /**
391
348
  * 1. Let url be the result of running the basic URL parser on input with
392
349
  * base, and encoding override as provided.
@@ -417,7 +374,7 @@ function urlParser(input, baseURL, encodingOverride) {
417
374
  * @param baseURL - base URL
418
375
  * @param encodingOverride - encoding override
419
376
  */
420
- function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
377
+ export function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
421
378
  /**
422
379
  * 1. If url is not given:
423
380
  * 1.1. Set url to a new URL.
@@ -452,7 +409,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
452
409
  * 7. If encoding override is given, set encoding to the result of getting
453
410
  * an output encoding from encoding override.
454
411
  */
455
- let state = (stateOverride === undefined ? interfaces_1.ParserState.SchemeStart : stateOverride);
412
+ let state = (stateOverride === undefined ? ParserState.SchemeStart : stateOverride);
456
413
  if (baseURL === undefined)
457
414
  baseURL = null;
458
415
  let encoding = (encodingOverride === undefined ||
@@ -468,7 +425,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
468
425
  let arrayFlag = false;
469
426
  let passwordTokenSeenFlag = false;
470
427
  const EOF = "";
471
- const walker = new util_1.StringWalker(input);
428
+ const walker = new StringWalker(input);
472
429
  /**
473
430
  * 11. Keep running the following state machine by switching on state. If
474
431
  * after a run pointer points to the EOF code point, go to the next step.
@@ -476,7 +433,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
476
433
  */
477
434
  while (true) {
478
435
  switch (state) {
479
- case interfaces_1.ParserState.SchemeStart:
436
+ case ParserState.SchemeStart:
480
437
  /**
481
438
  * 1. If c is an ASCII alpha, append c, lowercased, to buffer, and set
482
439
  * state to scheme state.
@@ -484,12 +441,12 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
484
441
  * state, and decrease pointer by one.
485
442
  * 3. Otherwise, validation error, return failure.
486
443
  */
487
- if (infra_1.codePoint.ASCIIAlpha.test(walker.c())) {
444
+ if (infraCodePoint.ASCIIAlpha.test(walker.c())) {
488
445
  buffer += walker.c().toLowerCase();
489
- state = interfaces_1.ParserState.Scheme;
446
+ state = ParserState.Scheme;
490
447
  }
491
448
  else if (stateOverride === undefined) {
492
- state = interfaces_1.ParserState.NoScheme;
449
+ state = ParserState.NoScheme;
493
450
  walker.pointer--;
494
451
  }
495
452
  else {
@@ -497,12 +454,12 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
497
454
  return null;
498
455
  }
499
456
  break;
500
- case interfaces_1.ParserState.Scheme:
457
+ case ParserState.Scheme:
501
458
  /**
502
459
  * 1. If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E
503
460
  * (.), append c, lowercased, to buffer.
504
461
  */
505
- if (infra_1.codePoint.ASCIIAlphanumeric.test(walker.c()) ||
462
+ if (infraCodePoint.ASCIIAlphanumeric.test(walker.c()) ||
506
463
  walker.c() === '+' || walker.c() === '-' || walker.c() === '.') {
507
464
  buffer += walker.c().toLowerCase();
508
465
  }
@@ -558,7 +515,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
558
515
  if (!walker.remaining().startsWith("//")) {
559
516
  validationError("Invalid file URL scheme, '//' expected.");
560
517
  }
561
- state = interfaces_1.ParserState.File;
518
+ state = ParserState.File;
562
519
  }
563
520
  else if (isSpecial(url) && baseURL !== null && baseURL.scheme === url.scheme) {
564
521
  /**
@@ -566,21 +523,21 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
566
523
  * scheme is equal to url’s scheme, set state to special relative
567
524
  * or authority state.
568
525
  */
569
- state = interfaces_1.ParserState.SpecialRelativeOrAuthority;
526
+ state = ParserState.SpecialRelativeOrAuthority;
570
527
  }
571
528
  else if (isSpecial(url)) {
572
529
  /**
573
530
  * 2.7. Otherwise, if url is special, set state to special
574
531
  * authority slashes state.
575
532
  */
576
- state = interfaces_1.ParserState.SpecialAuthoritySlashes;
533
+ state = ParserState.SpecialAuthoritySlashes;
577
534
  }
578
535
  else if (walker.remaining().startsWith("/")) {
579
536
  /**
580
537
  * 2.8. Otherwise, if remaining starts with an U+002F (/), set state
581
538
  * to path or authority state and increase pointer by one.
582
539
  */
583
- state = interfaces_1.ParserState.PathOrAuthority;
540
+ state = ParserState.PathOrAuthority;
584
541
  walker.pointer++;
585
542
  }
586
543
  else {
@@ -591,7 +548,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
591
548
  */
592
549
  url._cannotBeABaseURLFlag = true;
593
550
  url.path.push("");
594
- state = interfaces_1.ParserState.CannotBeABaseURLPath;
551
+ state = ParserState.CannotBeABaseURLPath;
595
552
  }
596
553
  }
597
554
  else if (stateOverride === undefined) {
@@ -601,7 +558,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
601
558
  * first code point in input).
602
559
  */
603
560
  buffer = "";
604
- state = interfaces_1.ParserState.NoScheme;
561
+ state = ParserState.NoScheme;
605
562
  walker.pointer = 0;
606
563
  continue;
607
564
  }
@@ -613,7 +570,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
613
570
  return null;
614
571
  }
615
572
  break;
616
- case interfaces_1.ParserState.NoScheme:
573
+ case ParserState.NoScheme:
617
574
  /**
618
575
  * 1. If base is null, or base’s cannot-be-a-base-URL flag is set
619
576
  * and c is not U+0023 (#), validation error, return failure.
@@ -632,22 +589,22 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
632
589
  }
633
590
  else if (baseURL._cannotBeABaseURLFlag && walker.c() === '#') {
634
591
  url.scheme = baseURL.scheme;
635
- url.path = infra_1.list.clone(baseURL.path);
592
+ url.path = infraList.clone(baseURL.path);
636
593
  url.query = baseURL.query;
637
594
  url.fragment = "";
638
595
  url._cannotBeABaseURLFlag = true;
639
- state = interfaces_1.ParserState.Fragment;
596
+ state = ParserState.Fragment;
640
597
  }
641
598
  else if (baseURL.scheme !== "file") {
642
- state = interfaces_1.ParserState.Relative;
599
+ state = ParserState.Relative;
643
600
  walker.pointer--;
644
601
  }
645
602
  else {
646
- state = interfaces_1.ParserState.File;
603
+ state = ParserState.File;
647
604
  walker.pointer--;
648
605
  }
649
606
  break;
650
- case interfaces_1.ParserState.SpecialRelativeOrAuthority:
607
+ case ParserState.SpecialRelativeOrAuthority:
651
608
  /**
652
609
  * If c is U+002F (/) and remaining starts with U+002F (/), then set
653
610
  * state to special authority ignore slashes state and increase
@@ -656,29 +613,29 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
656
613
  * decrease pointer by one.
657
614
  */
658
615
  if (walker.c() === '/' && walker.remaining().startsWith('/')) {
659
- state = interfaces_1.ParserState.SpecialAuthorityIgnoreSlashes;
616
+ state = ParserState.SpecialAuthorityIgnoreSlashes;
660
617
  walker.pointer++;
661
618
  }
662
619
  else {
663
620
  validationError("Invalid input string.");
664
- state = interfaces_1.ParserState.Relative;
621
+ state = ParserState.Relative;
665
622
  walker.pointer--;
666
623
  }
667
624
  break;
668
- case interfaces_1.ParserState.PathOrAuthority:
625
+ case ParserState.PathOrAuthority:
669
626
  /**
670
627
  * If c is U+002F (/), then set state to authority state.
671
628
  * Otherwise, set state to path state, and decrease pointer by one.
672
629
  */
673
630
  if (walker.c() === '/') {
674
- state = interfaces_1.ParserState.Authority;
631
+ state = ParserState.Authority;
675
632
  }
676
633
  else {
677
- state = interfaces_1.ParserState.Path;
634
+ state = ParserState.Path;
678
635
  walker.pointer--;
679
636
  }
680
637
  break;
681
- case interfaces_1.ParserState.Relative:
638
+ case ParserState.Relative:
682
639
  /**
683
640
  * Set url’s scheme to base’s scheme, and then, switching on c:
684
641
  */
@@ -698,14 +655,14 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
698
655
  url.password = baseURL.password;
699
656
  url.host = baseURL.host;
700
657
  url.port = baseURL.port;
701
- url.path = infra_1.list.clone(baseURL.path);
658
+ url.path = infraList.clone(baseURL.path);
702
659
  url.query = baseURL.query;
703
660
  break;
704
661
  case '/':
705
662
  /**
706
663
  * Set state to relative slash state.
707
664
  */
708
- state = interfaces_1.ParserState.RelativeSlash;
665
+ state = ParserState.RelativeSlash;
709
666
  break;
710
667
  case '?':
711
668
  /**
@@ -718,9 +675,9 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
718
675
  url.password = baseURL.password;
719
676
  url.host = baseURL.host;
720
677
  url.port = baseURL.port;
721
- url.path = infra_1.list.clone(baseURL.path);
678
+ url.path = infraList.clone(baseURL.path);
722
679
  url.query = "";
723
- state = interfaces_1.ParserState.Query;
680
+ state = ParserState.Query;
724
681
  break;
725
682
  case '#':
726
683
  /**
@@ -734,10 +691,10 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
734
691
  url.password = baseURL.password;
735
692
  url.host = baseURL.host;
736
693
  url.port = baseURL.port;
737
- url.path = infra_1.list.clone(baseURL.path);
694
+ url.path = infraList.clone(baseURL.path);
738
695
  url.query = baseURL.query;
739
696
  url.fragment = "";
740
- state = interfaces_1.ParserState.Fragment;
697
+ state = ParserState.Fragment;
741
698
  break;
742
699
  default:
743
700
  /**
@@ -752,23 +709,23 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
752
709
  */
753
710
  if (isSpecial(url) && walker.c() === '\\') {
754
711
  validationError("Invalid input string.");
755
- state = interfaces_1.ParserState.RelativeSlash;
712
+ state = ParserState.RelativeSlash;
756
713
  }
757
714
  else {
758
715
  url.username = baseURL.username;
759
716
  url.password = baseURL.password;
760
717
  url.host = baseURL.host;
761
718
  url.port = baseURL.port;
762
- url.path = infra_1.list.clone(baseURL.path);
719
+ url.path = infraList.clone(baseURL.path);
763
720
  if (url.path.length !== 0)
764
721
  url.path.splice(url.path.length - 1, 1);
765
- state = interfaces_1.ParserState.Path;
722
+ state = ParserState.Path;
766
723
  walker.pointer--;
767
724
  }
768
725
  break;
769
726
  }
770
727
  break;
771
- case interfaces_1.ParserState.RelativeSlash:
728
+ case ParserState.RelativeSlash:
772
729
  /**
773
730
  * 1. If url is special and c is U+002F (/) or U+005C (\), then:
774
731
  * 1.1. If c is U+005C (\), validation error.
@@ -782,10 +739,10 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
782
739
  if (walker.c() === '\\') {
783
740
  validationError("Invalid input string.");
784
741
  }
785
- state = interfaces_1.ParserState.SpecialAuthorityIgnoreSlashes;
742
+ state = ParserState.SpecialAuthorityIgnoreSlashes;
786
743
  }
787
744
  else if (walker.c() === '/') {
788
- state = interfaces_1.ParserState.Authority;
745
+ state = ParserState.Authority;
789
746
  }
790
747
  else {
791
748
  if (baseURL === null) {
@@ -795,11 +752,11 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
795
752
  url.password = baseURL.password;
796
753
  url.host = baseURL.host;
797
754
  url.port = baseURL.port;
798
- state = interfaces_1.ParserState.Path;
755
+ state = ParserState.Path;
799
756
  walker.pointer--;
800
757
  }
801
758
  break;
802
- case interfaces_1.ParserState.SpecialAuthoritySlashes:
759
+ case ParserState.SpecialAuthoritySlashes:
803
760
  /**
804
761
  * If c is U+002F (/) and remaining starts with U+002F (/), then set
805
762
  * state to special authority ignore slashes state and increase
@@ -808,30 +765,30 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
808
765
  * slashes state, and decrease pointer by one.
809
766
  */
810
767
  if (walker.c() === '/' && walker.remaining().startsWith('/')) {
811
- state = interfaces_1.ParserState.SpecialAuthorityIgnoreSlashes;
768
+ state = ParserState.SpecialAuthorityIgnoreSlashes;
812
769
  walker.pointer++;
813
770
  }
814
771
  else {
815
772
  validationError("Expected '//'.");
816
- state = interfaces_1.ParserState.SpecialAuthorityIgnoreSlashes;
773
+ state = ParserState.SpecialAuthorityIgnoreSlashes;
817
774
  walker.pointer--;
818
775
  }
819
776
  break;
820
- case interfaces_1.ParserState.SpecialAuthorityIgnoreSlashes:
777
+ case ParserState.SpecialAuthorityIgnoreSlashes:
821
778
  /**
822
779
  * If c is neither U+002F (/) nor U+005C (\), then set state to
823
780
  * authority state and decrease pointer by one.
824
781
  * Otherwise, validation error.
825
782
  */
826
783
  if (walker.c() !== '/' && walker.c() !== '\\') {
827
- state = interfaces_1.ParserState.Authority;
784
+ state = ParserState.Authority;
828
785
  walker.pointer--;
829
786
  }
830
787
  else {
831
788
  validationError("Unexpected '/' or '\\'.");
832
789
  }
833
790
  break;
834
- case interfaces_1.ParserState.Authority:
791
+ case ParserState.Authority:
835
792
  /**
836
793
  * 1. If c is U+0040 (@), then:
837
794
  */
@@ -891,7 +848,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
891
848
  }
892
849
  walker.pointer -= (buffer.length + 1);
893
850
  buffer = "";
894
- state = interfaces_1.ParserState.Host;
851
+ state = ParserState.Host;
895
852
  }
896
853
  else {
897
854
  /**
@@ -900,15 +857,15 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
900
857
  buffer += walker.c();
901
858
  }
902
859
  break;
903
- case interfaces_1.ParserState.Host:
904
- case interfaces_1.ParserState.Hostname:
860
+ case ParserState.Host:
861
+ case ParserState.Hostname:
905
862
  if (stateOverride !== undefined && url.scheme === "file") {
906
863
  /**
907
864
  * 1. If state override is given and url’s scheme is "file", then
908
865
  * decrease pointer by one and set state to file host state.
909
866
  */
910
867
  walker.pointer--;
911
- state = interfaces_1.ParserState.FileHost;
868
+ state = ParserState.FileHost;
912
869
  }
913
870
  else if (walker.c() === ':' && !arrayFlag) {
914
871
  /**
@@ -932,8 +889,8 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
932
889
  return null;
933
890
  url.host = host;
934
891
  buffer = "";
935
- state = interfaces_1.ParserState.Port;
936
- if (stateOverride === interfaces_1.ParserState.Hostname)
892
+ state = ParserState.Port;
893
+ if (stateOverride === ParserState.Hostname)
937
894
  return url;
938
895
  }
939
896
  else if (walker.c() === EOF || walker.c() === '/' || walker.c() === '?' || walker.c() === '#' ||
@@ -970,7 +927,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
970
927
  return null;
971
928
  url.host = host;
972
929
  buffer = "";
973
- state = interfaces_1.ParserState.PathStart;
930
+ state = ParserState.PathStart;
974
931
  if (stateOverride !== undefined)
975
932
  return url;
976
933
  }
@@ -988,8 +945,8 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
988
945
  buffer += walker.c();
989
946
  }
990
947
  break;
991
- case interfaces_1.ParserState.Port:
992
- if (infra_1.codePoint.ASCIIDigit.test(walker.c())) {
948
+ case ParserState.Port:
949
+ if (infraCodePoint.ASCIIDigit.test(walker.c())) {
993
950
  /**
994
951
  * 1. If c is an ASCII digit, append c to buffer.
995
952
  */
@@ -1033,7 +990,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1033
990
  if (stateOverride !== undefined) {
1034
991
  return url;
1035
992
  }
1036
- state = interfaces_1.ParserState.PathStart;
993
+ state = ParserState.PathStart;
1037
994
  walker.pointer--;
1038
995
  }
1039
996
  else {
@@ -1044,7 +1001,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1044
1001
  return null;
1045
1002
  }
1046
1003
  break;
1047
- case interfaces_1.ParserState.File:
1004
+ case ParserState.File:
1048
1005
  /**
1049
1006
  * 1. Set url’s scheme to "file".
1050
1007
  */
@@ -1058,7 +1015,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1058
1015
  if (walker.c() === '\\') {
1059
1016
  validationError("Invalid input string.");
1060
1017
  }
1061
- state = interfaces_1.ParserState.FileSlash;
1018
+ state = ParserState.FileSlash;
1062
1019
  }
1063
1020
  else if (baseURL !== null && baseURL.scheme === "file") {
1064
1021
  /**
@@ -1072,7 +1029,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1072
1029
  * path, and url’s query to base’s query.
1073
1030
  */
1074
1031
  url.host = baseURL.host;
1075
- url.path = infra_1.list.clone(baseURL.path);
1032
+ url.path = infraList.clone(baseURL.path);
1076
1033
  url.query = baseURL.query;
1077
1034
  break;
1078
1035
  case '?':
@@ -1082,9 +1039,9 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1082
1039
  * state.
1083
1040
  */
1084
1041
  url.host = baseURL.host;
1085
- url.path = infra_1.list.clone(baseURL.path);
1042
+ url.path = infraList.clone(baseURL.path);
1086
1043
  url.query = "";
1087
- state = interfaces_1.ParserState.Query;
1044
+ state = ParserState.Query;
1088
1045
  break;
1089
1046
  case '#':
1090
1047
  /**
@@ -1093,10 +1050,10 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1093
1050
  * empty string, and state to fragment state.
1094
1051
  */
1095
1052
  url.host = baseURL.host;
1096
- url.path = infra_1.list.clone(baseURL.path);
1053
+ url.path = infraList.clone(baseURL.path);
1097
1054
  url.query = baseURL.query;
1098
1055
  url.fragment = "";
1099
- state = interfaces_1.ParserState.Fragment;
1056
+ state = ParserState.Fragment;
1100
1057
  break;
1101
1058
  default:
1102
1059
  /**
@@ -1111,13 +1068,13 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1111
1068
  */
1112
1069
  if (!startsWithAWindowsDriveLetter(walker.substring())) {
1113
1070
  url.host = baseURL.host;
1114
- url.path = infra_1.list.clone(baseURL.path);
1071
+ url.path = infraList.clone(baseURL.path);
1115
1072
  shorten(url);
1116
1073
  }
1117
1074
  else {
1118
1075
  validationError("Unexpected windows drive letter in input string.");
1119
1076
  }
1120
- state = interfaces_1.ParserState.Path;
1077
+ state = ParserState.Path;
1121
1078
  walker.pointer--;
1122
1079
  break;
1123
1080
  }
@@ -1127,11 +1084,11 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1127
1084
  * 4. Otherwise, set state to path state, and decrease pointer by
1128
1085
  * one.
1129
1086
  */
1130
- state = interfaces_1.ParserState.Path;
1087
+ state = ParserState.Path;
1131
1088
  walker.pointer--;
1132
1089
  }
1133
1090
  break;
1134
- case interfaces_1.ParserState.FileSlash:
1091
+ case ParserState.FileSlash:
1135
1092
  if (walker.c() === '/' || walker.c() === '\\') {
1136
1093
  /**
1137
1094
  * 1. If c is U+002F (/) or U+005C (\), then:
@@ -1141,7 +1098,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1141
1098
  if (walker.c() === '\\') {
1142
1099
  validationError("Invalid input string.");
1143
1100
  }
1144
- state = interfaces_1.ParserState.FileHost;
1101
+ state = ParserState.FileHost;
1145
1102
  }
1146
1103
  else {
1147
1104
  /**
@@ -1166,11 +1123,11 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1166
1123
  url.host = baseURL.host;
1167
1124
  }
1168
1125
  }
1169
- state = interfaces_1.ParserState.Path;
1126
+ state = ParserState.Path;
1170
1127
  walker.pointer--;
1171
1128
  }
1172
1129
  break;
1173
- case interfaces_1.ParserState.FileHost:
1130
+ case ParserState.FileHost:
1174
1131
  if (walker.c() === EOF || walker.c() === '/' || walker.c() === '\\' ||
1175
1132
  walker.c() === '?' || walker.c() === '#') {
1176
1133
  /**
@@ -1186,7 +1143,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1186
1143
  * quirk. buffer is not reset here and instead used in the path state.
1187
1144
  */
1188
1145
  validationError("Unexpected windows drive letter in input string.");
1189
- state = interfaces_1.ParserState.Path;
1146
+ state = ParserState.Path;
1190
1147
  }
1191
1148
  else if (buffer === "") {
1192
1149
  /**
@@ -1198,7 +1155,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1198
1155
  url.host = "";
1199
1156
  if (stateOverride !== undefined)
1200
1157
  return url;
1201
- state = interfaces_1.ParserState.PathStart;
1158
+ state = ParserState.PathStart;
1202
1159
  }
1203
1160
  else {
1204
1161
  /**
@@ -1222,7 +1179,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1222
1179
  if (stateOverride !== undefined)
1223
1180
  return url;
1224
1181
  buffer = "";
1225
- state = interfaces_1.ParserState.PathStart;
1182
+ state = ParserState.PathStart;
1226
1183
  }
1227
1184
  }
1228
1185
  else {
@@ -1232,7 +1189,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1232
1189
  buffer += walker.c();
1233
1190
  }
1234
1191
  break;
1235
- case interfaces_1.ParserState.PathStart:
1192
+ case ParserState.PathStart:
1236
1193
  if (isSpecial(url)) {
1237
1194
  /**
1238
1195
  * 1. If url is special, then:
@@ -1244,7 +1201,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1244
1201
  if (walker.c() === '\\') {
1245
1202
  validationError("Invalid input string.");
1246
1203
  }
1247
- state = interfaces_1.ParserState.Path;
1204
+ state = ParserState.Path;
1248
1205
  if (walker.c() !== '/' && walker.c() !== '\\')
1249
1206
  walker.pointer--;
1250
1207
  }
@@ -1254,7 +1211,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1254
1211
  * set url’s query to the empty string and state to query state.
1255
1212
  */
1256
1213
  url.query = "";
1257
- state = interfaces_1.ParserState.Query;
1214
+ state = ParserState.Query;
1258
1215
  }
1259
1216
  else if (stateOverride === undefined && walker.c() === '#') {
1260
1217
  /**
@@ -1263,7 +1220,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1263
1220
  * state.
1264
1221
  */
1265
1222
  url.fragment = "";
1266
- state = interfaces_1.ParserState.Fragment;
1223
+ state = ParserState.Fragment;
1267
1224
  }
1268
1225
  else if (walker.c() !== EOF) {
1269
1226
  /**
@@ -1271,12 +1228,12 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1271
1228
  * 4.1. Set state to path state.
1272
1229
  * 4.2. If c is not U+002F (/), then decrease pointer by one.
1273
1230
  */
1274
- state = interfaces_1.ParserState.Path;
1231
+ state = ParserState.Path;
1275
1232
  if (walker.c() !== '/')
1276
1233
  walker.pointer--;
1277
1234
  }
1278
1235
  break;
1279
- case interfaces_1.ParserState.Path:
1236
+ case ParserState.Path:
1280
1237
  if ((walker.c() === EOF || walker.c() === '/') ||
1281
1238
  (isSpecial(url) && walker.c() === '\\') ||
1282
1239
  (stateOverride === undefined && (walker.c() === '?' || walker.c() === '#'))) {
@@ -1363,11 +1320,11 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1363
1320
  */
1364
1321
  if (walker.c() === '?') {
1365
1322
  url.query = "";
1366
- state = interfaces_1.ParserState.Query;
1323
+ state = ParserState.Query;
1367
1324
  }
1368
1325
  if (walker.c() === '#') {
1369
1326
  url.fragment = "";
1370
- state = interfaces_1.ParserState.Fragment;
1327
+ state = ParserState.Fragment;
1371
1328
  }
1372
1329
  }
1373
1330
  else {
@@ -1389,7 +1346,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1389
1346
  buffer += utf8PercentEncode(walker.c(), _pathPercentEncodeSet);
1390
1347
  }
1391
1348
  break;
1392
- case interfaces_1.ParserState.CannotBeABaseURLPath:
1349
+ case ParserState.CannotBeABaseURLPath:
1393
1350
  /**
1394
1351
  * 1. If c is U+003F (?), then set url’s query to the empty string and
1395
1352
  * state to query state.
@@ -1406,11 +1363,11 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1406
1363
  */
1407
1364
  if (walker.c() === '?') {
1408
1365
  url.query = "";
1409
- state = interfaces_1.ParserState.Query;
1366
+ state = ParserState.Query;
1410
1367
  }
1411
1368
  else if (walker.c() === '#') {
1412
1369
  url.fragment = "";
1413
- state = interfaces_1.ParserState.Fragment;
1370
+ state = ParserState.Fragment;
1414
1371
  }
1415
1372
  else {
1416
1373
  if (walker.c() !== EOF && !_urlCodePoints.test(walker.c()) && walker.c() !== '%') {
@@ -1424,7 +1381,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1424
1381
  }
1425
1382
  }
1426
1383
  break;
1427
- case interfaces_1.ParserState.Query:
1384
+ case ParserState.Query:
1428
1385
  /**
1429
1386
  * 1. If encoding is not UTF-8 and one of the following is true
1430
1387
  * - url is not special
@@ -1441,7 +1398,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1441
1398
  * url’s fragment to the empty string and state to fragment state.
1442
1399
  */
1443
1400
  url.fragment = "";
1444
- state = interfaces_1.ParserState.Fragment;
1401
+ state = ParserState.Fragment;
1445
1402
  }
1446
1403
  else if (walker.c() !== EOF) {
1447
1404
  /**
@@ -1465,7 +1422,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1465
1422
  if (encoding.toUpperCase() !== "UTF-8") {
1466
1423
  throw new Error("Only UTF-8 encoding is supported.");
1467
1424
  }
1468
- let bytes = (0, util_1.utf8Encode)(walker.c());
1425
+ let bytes = utf8Encode(walker.c());
1469
1426
  /**
1470
1427
  * 3.4. If bytes starts with `&#` and ends with 0x3B (;), then:
1471
1428
  */
@@ -1479,7 +1436,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1479
1436
  * non-UTF-8 encoding.
1480
1437
  */
1481
1438
  bytes = bytes.subarray(2, bytes.length - 1);
1482
- url.query += "%26%23" + infra_1.byteSequence.isomorphicDecode(bytes) + "%3B";
1439
+ url.query += "%26%23" + infraByteSequence.isomorphicDecode(bytes) + "%3B";
1483
1440
  }
1484
1441
  else {
1485
1442
  /**
@@ -1506,7 +1463,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1506
1463
  }
1507
1464
  }
1508
1465
  break;
1509
- case interfaces_1.ParserState.Fragment:
1466
+ case ParserState.Fragment:
1510
1467
  /**
1511
1468
  * Switching on c:
1512
1469
  * - The EOF code point
@@ -1554,7 +1511,7 @@ function basicURLParser(input, baseURL, encodingOverride, url, stateOverride) {
1554
1511
  * @param url - a URL
1555
1512
  * @param username - username string
1556
1513
  */
1557
- function setTheUsername(url, username) {
1514
+ export function setTheUsername(url, username) {
1558
1515
  /**
1559
1516
  * 1. Set url’s username to the empty string.
1560
1517
  * 2. For each code point in username, UTF-8 percent encode it using the
@@ -1572,7 +1529,7 @@ function setTheUsername(url, username) {
1572
1529
  * @param url - a URL
1573
1530
  * @param username - password string
1574
1531
  */
1575
- function setThePassword(url, password) {
1532
+ export function setThePassword(url, password) {
1576
1533
  /**
1577
1534
  * 1. Set url’s password to the empty string.
1578
1535
  * 2. For each code point in password, UTF-8 percent encode it using the
@@ -1589,7 +1546,7 @@ function setThePassword(url, password) {
1589
1546
  *
1590
1547
  * @param str - a string
1591
1548
  */
1592
- function isSingleDotPathSegment(str) {
1549
+ export function isSingleDotPathSegment(str) {
1593
1550
  return str === '.' || str.toLowerCase() === "%2e";
1594
1551
  }
1595
1552
  /**
@@ -1597,7 +1554,7 @@ function isSingleDotPathSegment(str) {
1597
1554
  *
1598
1555
  * @param str - a string
1599
1556
  */
1600
- function isDoubleDotPathSegment(str) {
1557
+ export function isDoubleDotPathSegment(str) {
1601
1558
  const lowerStr = str.toLowerCase();
1602
1559
  return lowerStr === ".." || lowerStr === ".%2e" ||
1603
1560
  lowerStr === "%2e." || lowerStr === "%2e%2e";
@@ -1607,7 +1564,7 @@ function isDoubleDotPathSegment(str) {
1607
1564
  *
1608
1565
  * @param url - an URL
1609
1566
  */
1610
- function shorten(url) {
1567
+ export function shorten(url) {
1611
1568
  /**
1612
1569
  * 1. Let path be url’s path.
1613
1570
  * 2. If path is empty, then return.
@@ -1628,12 +1585,12 @@ function shorten(url) {
1628
1585
  *
1629
1586
  * @param str - a string
1630
1587
  */
1631
- function isNormalizedWindowsDriveLetter(str) {
1588
+ export function isNormalizedWindowsDriveLetter(str) {
1632
1589
  /**
1633
1590
  * A normalized Windows drive letter is a Windows drive letter of which the
1634
1591
  * second code point is U+003A (:).
1635
1592
  */
1636
- return str.length >= 2 && infra_1.codePoint.ASCIIAlpha.test(str[0]) &&
1593
+ return str.length >= 2 && infraCodePoint.ASCIIAlpha.test(str[0]) &&
1637
1594
  str[1] === ':';
1638
1595
  }
1639
1596
  /**
@@ -1641,12 +1598,12 @@ function isNormalizedWindowsDriveLetter(str) {
1641
1598
  *
1642
1599
  * @param str - a string
1643
1600
  */
1644
- function isWindowsDriveLetter(str) {
1601
+ export function isWindowsDriveLetter(str) {
1645
1602
  /**
1646
1603
  * A Windows drive letter is two code points, of which the first is an ASCII
1647
1604
  * alpha and the second is either U+003A (:) or U+007C (|).
1648
1605
  */
1649
- return str.length >= 2 && infra_1.codePoint.ASCIIAlpha.test(str[0]) &&
1606
+ return str.length >= 2 && infraCodePoint.ASCIIAlpha.test(str[0]) &&
1650
1607
  (str[1] === ':' || str[1] === '|');
1651
1608
  }
1652
1609
  /**
@@ -1654,7 +1611,7 @@ function isWindowsDriveLetter(str) {
1654
1611
  *
1655
1612
  * @param str - a string
1656
1613
  */
1657
- function startsWithAWindowsDriveLetter(str) {
1614
+ export function startsWithAWindowsDriveLetter(str) {
1658
1615
  /**
1659
1616
  * A string starts with a Windows drive letter if all of the following are
1660
1617
  * true:
@@ -1674,7 +1631,7 @@ function startsWithAWindowsDriveLetter(str) {
1674
1631
  * @param isNotSpecial - `true` if the source URL is not special; otherwise
1675
1632
  * `false`.
1676
1633
  */
1677
- function hostParser(input, isNotSpecial = false) {
1634
+ export function hostParser(input, isNotSpecial = false) {
1678
1635
  /**
1679
1636
  * 1. If isNotSpecial is not given, then set isNotSpecial to false.
1680
1637
  * 2. If input starts with U+005B ([), then:
@@ -1704,7 +1661,7 @@ function hostParser(input, isNotSpecial = false) {
1704
1661
  * coupled with an early return for failure, as domain to ASCII fails
1705
1662
  * on U+FFFD REPLACEMENT CHARACTER.
1706
1663
  */
1707
- const domain = (0, util_1.utf8Decode)(stringPercentDecode(input));
1664
+ const domain = utf8Decode(stringPercentDecode(input));
1708
1665
  /**
1709
1666
  * 5. Let asciiDomain be the result of running domain to ASCII on domain.
1710
1667
  * 6. If asciiDomain is failure, validation error, return failure.
@@ -1726,7 +1683,7 @@ function hostParser(input, isNotSpecial = false) {
1726
1683
  * 10. Return asciiDomain.
1727
1684
  */
1728
1685
  const ipv4Host = iPv4Parser(asciiDomain);
1729
- if (ipv4Host === null || (0, util_1.isNumber)(ipv4Host))
1686
+ if (ipv4Host === null || isNumber(ipv4Host))
1730
1687
  return ipv4Host;
1731
1688
  return asciiDomain;
1732
1689
  }
@@ -1737,7 +1694,7 @@ function hostParser(input, isNotSpecial = false) {
1737
1694
  * @param isNotSpecial - `true` if the source URL is not special; otherwise
1738
1695
  * `false`.
1739
1696
  */
1740
- function iPv4NumberParser(input, validationErrorFlag = { value: false }) {
1697
+ export function iPv4NumberParser(input, validationErrorFlag = { value: false }) {
1741
1698
  /**
1742
1699
  * 1. Let R be 10.
1743
1700
  */
@@ -1788,7 +1745,7 @@ function iPv4NumberParser(input, validationErrorFlag = { value: false }) {
1788
1745
  *
1789
1746
  * @param input - input string
1790
1747
  */
1791
- function iPv4Parser(input) {
1748
+ export function iPv4Parser(input) {
1792
1749
  /**
1793
1750
  * 1. Let validationErrorFlag be unset.
1794
1751
  * 2. Let parts be input split on U+002E (.).
@@ -1877,7 +1834,7 @@ function iPv4Parser(input) {
1877
1834
  *
1878
1835
  * @param input - input string
1879
1836
  */
1880
- function iPv6Parser(input) {
1837
+ export function iPv6Parser(input) {
1881
1838
  /**
1882
1839
  * 1. Let address be a new IPv6 address whose IPv6 pieces are all 0.
1883
1840
  * 2. Let pieceIndex be 0.
@@ -1889,7 +1846,7 @@ function iPv6Parser(input) {
1889
1846
  const address = [0, 0, 0, 0, 0, 0, 0, 0];
1890
1847
  let pieceIndex = 0;
1891
1848
  let compress = null;
1892
- const walker = new util_1.StringWalker(input);
1849
+ const walker = new StringWalker(input);
1893
1850
  /**
1894
1851
  * 5. If c is U+003A (:), then:
1895
1852
  * 5.1. If remaining does not start with U+003A (:), validation error,
@@ -1941,7 +1898,7 @@ function iPv6Parser(input) {
1941
1898
  */
1942
1899
  let value = 0;
1943
1900
  let length = 0;
1944
- while (length < 4 && infra_1.codePoint.ASCIIHexDigit.test(walker.c())) {
1901
+ while (length < 4 && infraCodePoint.ASCIIHexDigit.test(walker.c())) {
1945
1902
  value = value * 0x10 + parseInt(walker.c(), 16);
1946
1903
  walker.pointer++;
1947
1904
  length++;
@@ -1994,14 +1951,14 @@ function iPv6Parser(input) {
1994
1951
  * 6.5.5.3. If c is not an ASCII digit, validation error, return
1995
1952
  * failure.
1996
1953
  */
1997
- if (!infra_1.codePoint.ASCIIDigit.test(walker.c())) {
1954
+ if (!infraCodePoint.ASCIIDigit.test(walker.c())) {
1998
1955
  validationError("Invalid IP v6 address.");
1999
1956
  return null;
2000
1957
  }
2001
1958
  /**
2002
1959
  * 6.5.5.4. While c is an ASCII digit:
2003
1960
  */
2004
- while (infra_1.codePoint.ASCIIDigit.test(walker.c())) {
1961
+ while (infraCodePoint.ASCIIDigit.test(walker.c())) {
2005
1962
  /**
2006
1963
  * 6.5.5.4.1. Let number be c interpreted as decimal number.
2007
1964
  */
@@ -2120,7 +2077,7 @@ function iPv6Parser(input) {
2120
2077
  *
2121
2078
  * @param input - a string
2122
2079
  */
2123
- function opaqueHostParser(input) {
2080
+ export function opaqueHostParser(input) {
2124
2081
  /**
2125
2082
  * 1. If input contains a forbidden host code point excluding U+0025 (%),
2126
2083
  * validation error, return failure.
@@ -2147,7 +2104,7 @@ function opaqueHostParser(input) {
2147
2104
  *
2148
2105
  * @param url - an url
2149
2106
  */
2150
- function resolveABlobURL(url) {
2107
+ export function resolveABlobURL(url) {
2151
2108
  return null;
2152
2109
  }
2153
2110
  /**
@@ -2155,7 +2112,7 @@ function resolveABlobURL(url) {
2155
2112
  *
2156
2113
  * @param value - a byte
2157
2114
  */
2158
- function percentEncode(value) {
2115
+ export function percentEncode(value) {
2159
2116
  /**
2160
2117
  * To percent encode a byte into a percent-encoded byte, return a string
2161
2118
  * consisting of U+0025 (%), followed by two ASCII upper hex digits
@@ -2168,7 +2125,7 @@ function percentEncode(value) {
2168
2125
  *
2169
2126
  * @param input - a byte sequence
2170
2127
  */
2171
- function percentDecode(input) {
2128
+ export function percentDecode(input) {
2172
2129
  const isHexDigit = (byte) => {
2173
2130
  return (byte >= 0x30 && byte <= 0x39) || (byte >= 0x41 && byte <= 0x46) ||
2174
2131
  (byte >= 0x61 && byte <= 0x66);
@@ -2206,7 +2163,7 @@ function percentDecode(input) {
2206
2163
  n++;
2207
2164
  }
2208
2165
  else {
2209
- const bytePoint = parseInt((0, util_1.utf8Decode)(Uint8Array.of(input[i + 1], input[i + 2])), 16);
2166
+ const bytePoint = parseInt(utf8Decode(Uint8Array.of(input[i + 1], input[i + 2])), 16);
2210
2167
  output[n] = bytePoint;
2211
2168
  n++;
2212
2169
  i += 2;
@@ -2219,12 +2176,12 @@ function percentDecode(input) {
2219
2176
  *
2220
2177
  * @param input - a string
2221
2178
  */
2222
- function stringPercentDecode(input) {
2179
+ export function stringPercentDecode(input) {
2223
2180
  /**
2224
2181
  * 1. Let bytes be the UTF-8 encoding of input.
2225
2182
  * 2. Return the percent decoding of bytes.
2226
2183
  */
2227
- return percentDecode((0, util_1.utf8Encode)(input));
2184
+ return percentDecode(utf8Encode(input));
2228
2185
  }
2229
2186
  /**
2230
2187
  * UTF-8 percent encodes a code point, using a percent encode set.
@@ -2232,7 +2189,7 @@ function stringPercentDecode(input) {
2232
2189
  * @param codePoint - a code point
2233
2190
  * @param percentEncodeSet - a percent encode set
2234
2191
  */
2235
- function utf8PercentEncode(codePoint, percentEncodeSet) {
2192
+ export function utf8PercentEncode(codePoint, percentEncodeSet) {
2236
2193
  /**
2237
2194
  * 1. If codePoint is not in percentEncodeSet, then return codePoint.
2238
2195
  * 2. Let bytes be the result of running UTF-8 encode on codePoint.
@@ -2241,7 +2198,7 @@ function utf8PercentEncode(codePoint, percentEncodeSet) {
2241
2198
  */
2242
2199
  if (!percentEncodeSet.test(codePoint))
2243
2200
  return codePoint;
2244
- const bytes = (0, util_1.utf8Encode)(codePoint);
2201
+ const bytes = utf8Encode(codePoint);
2245
2202
  let result = "";
2246
2203
  for (const byte of bytes) {
2247
2204
  result += percentEncode(byte);
@@ -2254,7 +2211,7 @@ function utf8PercentEncode(codePoint, percentEncodeSet) {
2254
2211
  * @param hostA - a host
2255
2212
  * @param hostB - a host
2256
2213
  */
2257
- function hostEquals(hostA, hostB) {
2214
+ export function hostEquals(hostA, hostB) {
2258
2215
  return hostA === hostB;
2259
2216
  }
2260
2217
  /**
@@ -2264,7 +2221,7 @@ function hostEquals(hostA, hostB) {
2264
2221
  * @param urlB - a URL
2265
2222
  * @param excludeFragmentsFlag - whether to ignore fragments while comparing
2266
2223
  */
2267
- function urlEquals(urlA, urlB, excludeFragmentsFlag = false) {
2224
+ export function urlEquals(urlA, urlB, excludeFragmentsFlag = false) {
2268
2225
  /**
2269
2226
  * 1. Let serializedA be the result of serializing A, with the exclude
2270
2227
  * fragment flag set if the exclude fragments flag is set.
@@ -2280,20 +2237,20 @@ function urlEquals(urlA, urlB, excludeFragmentsFlag = false) {
2280
2237
  *
2281
2238
  * @param input - a string
2282
2239
  */
2283
- function urlEncodedStringParser(input) {
2240
+ export function urlEncodedStringParser(input) {
2284
2241
  /**
2285
2242
  * The application/x-www-form-urlencoded string parser takes a string input,
2286
2243
  * UTF-8 encodes it, and then returns the result of
2287
2244
  * application/x-www-form-urlencoded parsing it.
2288
2245
  */
2289
- return urlEncodedParser((0, util_1.utf8Encode)(input));
2246
+ return urlEncodedParser(utf8Encode(input));
2290
2247
  }
2291
2248
  /**
2292
2249
  * Parses `application/x-www-form-urlencoded` bytes.
2293
2250
  *
2294
2251
  * @param input - a byte sequence
2295
2252
  */
2296
- function urlEncodedParser(input) {
2253
+ export function urlEncodedParser(input) {
2297
2254
  /**
2298
2255
  * 1. Let sequences be the result of splitting input on 0x26 (&).
2299
2256
  */
@@ -2350,8 +2307,8 @@ function urlEncodedParser(input) {
2350
2307
  * decode without BOM on the percent decoding of name and value,
2351
2308
  * respectively.
2352
2309
  */
2353
- const nameString = (0, util_1.utf8Decode)(name);
2354
- const valueString = (0, util_1.utf8Decode)(value);
2310
+ const nameString = utf8Decode(name);
2311
+ const valueString = utf8Decode(value);
2355
2312
  /**
2356
2313
  * 3.6. Append (nameString, valueString) to output.
2357
2314
  */
@@ -2367,7 +2324,7 @@ function urlEncodedParser(input) {
2367
2324
  *
2368
2325
  * @param input - a byte sequence
2369
2326
  */
2370
- function urlEncodedByteSerializer(input) {
2327
+ export function urlEncodedByteSerializer(input) {
2371
2328
  /**
2372
2329
  * 1. Let output be the empty string.
2373
2330
  * 2. For each byte in input, depending on byte:
@@ -2409,7 +2366,7 @@ function urlEncodedByteSerializer(input) {
2409
2366
  * @param input - input tuple of name/value pairs
2410
2367
  * @param encodingOverride: encoding override
2411
2368
  */
2412
- function urlEncodedSerializer(tuples, encodingOverride) {
2369
+ export function urlEncodedSerializer(tuples, encodingOverride) {
2413
2370
  /**
2414
2371
  * 1. Let encoding be UTF-8.
2415
2372
  * 2. If encoding override is given, set encoding to the result of getting
@@ -2433,7 +2390,7 @@ function urlEncodedSerializer(tuples, encodingOverride) {
2433
2390
  * 4.1. Let name be the result of serializing the result of encoding
2434
2391
  * tuple’s name, using encoding.
2435
2392
  */
2436
- const name = urlEncodedByteSerializer((0, util_1.utf8Encode)(tuple[0]));
2393
+ const name = urlEncodedByteSerializer(utf8Encode(tuple[0]));
2437
2394
  /**
2438
2395
  * 4.2. Let value be tuple’s value.
2439
2396
  */
@@ -2446,7 +2403,7 @@ function urlEncodedSerializer(tuples, encodingOverride) {
2446
2403
  * 4.4. Set value to the result of serializing the result of encoding
2447
2404
  * value, using encoding.
2448
2405
  */
2449
- value = urlEncodedByteSerializer((0, util_1.utf8Encode)(value));
2406
+ value = urlEncodedByteSerializer(utf8Encode(value));
2450
2407
  /**
2451
2408
  * 4.5. If tuple is not the first pair in tuples, then append U+0026 (&)
2452
2409
  * to output.
@@ -2468,7 +2425,7 @@ function urlEncodedSerializer(tuples, encodingOverride) {
2468
2425
  *
2469
2426
  * @param url - a URL
2470
2427
  */
2471
- function origin(url) {
2428
+ export function origin(url) {
2472
2429
  /**
2473
2430
  * A URL’s origin is the origin returned by running these steps, switching
2474
2431
  * on URL’s scheme:
@@ -2498,7 +2455,7 @@ function origin(url) {
2498
2455
  }
2499
2456
  const parsedURL = basicURLParser(url.path[0]);
2500
2457
  if (parsedURL === null)
2501
- return interfaces_1.OpaqueOrigin;
2458
+ return OpaqueOrigin;
2502
2459
  else
2503
2460
  return origin(parsedURL);
2504
2461
  case "ftp":
@@ -2508,9 +2465,9 @@ function origin(url) {
2508
2465
  case "wss":
2509
2466
  return [url.scheme, url.host === null ? "" : url.host, url.port, null];
2510
2467
  case "file":
2511
- return interfaces_1.OpaqueOrigin;
2468
+ return OpaqueOrigin;
2512
2469
  default:
2513
- return interfaces_1.OpaqueOrigin;
2470
+ return OpaqueOrigin;
2514
2471
  }
2515
2472
  }
2516
2473
  /**
@@ -2518,7 +2475,7 @@ function origin(url) {
2518
2475
  *
2519
2476
  * @param domain - a domain string
2520
2477
  */
2521
- function domainToASCII(domain, beStrict = false) {
2478
+ export function domainToASCII(domain, beStrict = false) {
2522
2479
  /**
2523
2480
  * 1. If beStrict is not given, set it to false.
2524
2481
  * 2. Let result be the result of running Unicode ToASCII with domain_name
@@ -2529,7 +2486,7 @@ function domainToASCII(domain, beStrict = false) {
2529
2486
  * 4. Return result.
2530
2487
  */
2531
2488
  // Use node.js function
2532
- const result = (0, url_1.domainToASCII)(domain);
2489
+ const result = nodeDomainToASCII(domain);
2533
2490
  if (result === "") {
2534
2491
  validationError("Invalid domain name.");
2535
2492
  return null;
@@ -2541,7 +2498,7 @@ function domainToASCII(domain, beStrict = false) {
2541
2498
  *
2542
2499
  * @param domain - a domain string
2543
2500
  */
2544
- function domainToUnicode(domain, beStrict = false) {
2501
+ export function domainToUnicode(domain, beStrict = false) {
2545
2502
  /**
2546
2503
  * 1. Let result be the result of running Unicode ToUnicode with domain_name
2547
2504
  * set to domain, CheckHyphens set to false, CheckBidi set to true,
@@ -2551,7 +2508,7 @@ function domainToUnicode(domain, beStrict = false) {
2551
2508
  * return result.
2552
2509
  */
2553
2510
  // Use node.js function
2554
- const result = (0, url_1.domainToUnicode)(domain);
2511
+ const result = nodeDomainToUnicode(domain);
2555
2512
  if (result === "") {
2556
2513
  validationError("Invalid domain name.");
2557
2514
  }
@@ -2564,7 +2521,7 @@ function domainToUnicode(domain, beStrict = false) {
2564
2521
  *
2565
2522
  * @param origin - an origin
2566
2523
  */
2567
- function asciiSerializationOfAnOrigin(origin) {
2524
+ export function asciiSerializationOfAnOrigin(origin) {
2568
2525
  /**
2569
2526
  * 1. If origin is an opaque origin, then return "null".
2570
2527
  * 2. Otherwise, let result be origin's scheme.