@oozcitak/url 4.0.0 → 4.0.1

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