tldts-experimental 5.7.79 → 5.7.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -416,7 +416,7 @@ function resetResult(result) {
416
416
  result.subdomain = null;
417
417
  }
418
418
  function parseImpl(url, step, suffixLookup, partialOptions, result) {
419
- const options = setDefaults(partialOptions);
419
+ const options = /*@__INLINE__*/ setDefaults(partialOptions);
420
420
  // Very fast approximate check to make sure `url` is a string. This is needed
421
421
  // because the library will not necessarily be used in a typed setup and
422
422
  // values of arbitrary types might be given as argument.
@@ -442,7 +442,7 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
442
442
  else {
443
443
  result.hostname = extractHostname(url, false);
444
444
  }
445
- if (step === 0 /* HOSTNAME */ || result.hostname === null) {
445
+ if (step === 0 /* FLAG.HOSTNAME */ || result.hostname === null) {
446
446
  return result;
447
447
  }
448
448
  // Check if `hostname` is a valid ip address
@@ -462,17 +462,17 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
462
462
  }
463
463
  // Extract public suffix
464
464
  suffixLookup(result.hostname, options, result);
465
- if (step === 2 /* PUBLIC_SUFFIX */ || result.publicSuffix === null) {
465
+ if (step === 2 /* FLAG.PUBLIC_SUFFIX */ || result.publicSuffix === null) {
466
466
  return result;
467
467
  }
468
468
  // Extract domain
469
469
  result.domain = getDomain$1(result.publicSuffix, result.hostname, options);
470
- if (step === 3 /* DOMAIN */ || result.domain === null) {
470
+ if (step === 3 /* FLAG.DOMAIN */ || result.domain === null) {
471
471
  return result;
472
472
  }
473
473
  // Extract subdomain
474
474
  result.subdomain = getSubdomain$1(result.hostname, result.domain);
475
- if (step === 4 /* SUB_DOMAIN */) {
475
+ if (step === 4 /* FLAG.SUB_DOMAIN */) {
476
476
  return result;
477
477
  }
478
478
  // Extract domain without suffix
@@ -625,7 +625,7 @@ function suffixLookup(hostname, options, out) {
625
625
  const { allowIcannDomains, allowPrivateDomains } = options;
626
626
  // Keep track of longest match
627
627
  let matchIndex = -1;
628
- let matchKind = 0 /* NO_MATCH */;
628
+ let matchKind = 0 /* Result.NO_MATCH */;
629
629
  let matchLabels = 0; // Keep track of number of labels currently matched
630
630
  // Index in the packed array data-structure
631
631
  let index = 1;
@@ -653,22 +653,22 @@ function suffixLookup(hostname, options, out) {
653
653
  //
654
654
  // **WARNING**: the structure of this code follows exactly the structure
655
655
  // of the packed data structure as create in ./bin/builders/hashes.js
656
- let match = 0 /* NO_MATCH */;
656
+ let match = 0 /* Result.NO_MATCH */;
657
657
  // ========================================================================
658
658
  // Lookup exceptions
659
659
  // ========================================================================
660
660
  // ICANN
661
661
  if (allowIcannDomains === true) {
662
662
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
663
- ? 1 /* ICANN_MATCH */ | 4 /* EXCEPTION_MATCH */
664
- : 0 /* NO_MATCH */;
663
+ ? 1 /* Result.ICANN_MATCH */ | 4 /* Result.EXCEPTION_MATCH */
664
+ : 0 /* Result.NO_MATCH */;
665
665
  }
666
666
  index += packed[index] + 1;
667
667
  // PRIVATE
668
- if (allowPrivateDomains === true && match === 0 /* NO_MATCH */) {
668
+ if (allowPrivateDomains === true && match === 0 /* Result.NO_MATCH */) {
669
669
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
670
- ? 2 /* PRIVATE_MATCH */ | 4 /* EXCEPTION_MATCH */
671
- : 0 /* NO_MATCH */;
670
+ ? 2 /* Result.PRIVATE_MATCH */ | 4 /* Result.EXCEPTION_MATCH */
671
+ : 0 /* Result.NO_MATCH */;
672
672
  }
673
673
  index += packed[index] + 1;
674
674
  // ========================================================================
@@ -676,20 +676,20 @@ function suffixLookup(hostname, options, out) {
676
676
  // ========================================================================
677
677
  // ICANN
678
678
  if (allowIcannDomains === true &&
679
- match === 0 /* NO_MATCH */ &&
680
- (matchKind & 4 /* EXCEPTION_MATCH */) === 0) {
679
+ match === 0 /* Result.NO_MATCH */ &&
680
+ (matchKind & 4 /* Result.EXCEPTION_MATCH */) === 0) {
681
681
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
682
- ? 16 /* WILDCARD_MATCH */ | 1 /* ICANN_MATCH */
683
- : 0 /* NO_MATCH */;
682
+ ? 16 /* Result.WILDCARD_MATCH */ | 1 /* Result.ICANN_MATCH */
683
+ : 0 /* Result.NO_MATCH */;
684
684
  }
685
685
  index += packed[index] + 1;
686
686
  // PRIVATE
687
687
  if (allowPrivateDomains === true &&
688
- match === 0 /* NO_MATCH */ &&
689
- (matchKind & 4 /* EXCEPTION_MATCH */) === 0) {
688
+ match === 0 /* Result.NO_MATCH */ &&
689
+ (matchKind & 4 /* Result.EXCEPTION_MATCH */) === 0) {
690
690
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
691
- ? 16 /* WILDCARD_MATCH */ | 2 /* PRIVATE_MATCH */
692
- : 0 /* NO_MATCH */;
691
+ ? 16 /* Result.WILDCARD_MATCH */ | 2 /* Result.PRIVATE_MATCH */
692
+ : 0 /* Result.NO_MATCH */;
693
693
  }
694
694
  index += packed[index] + 1;
695
695
  // ========================================================================
@@ -697,22 +697,22 @@ function suffixLookup(hostname, options, out) {
697
697
  // ========================================================================
698
698
  // ICANN
699
699
  if (allowIcannDomains === true &&
700
- match === 0 /* NO_MATCH */ &&
701
- (matchKind & 4 /* EXCEPTION_MATCH */) === 0 &&
700
+ match === 0 /* Result.NO_MATCH */ &&
701
+ (matchKind & 4 /* Result.EXCEPTION_MATCH */) === 0 &&
702
702
  matchLabels <= label) {
703
703
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
704
- ? 8 /* NORMAL_MATCH */ | 1 /* ICANN_MATCH */
705
- : 0 /* NO_MATCH */;
704
+ ? 8 /* Result.NORMAL_MATCH */ | 1 /* Result.ICANN_MATCH */
705
+ : 0 /* Result.NO_MATCH */;
706
706
  }
707
707
  index += packed[index] + 1;
708
708
  // PRIVATE
709
709
  if (allowPrivateDomains === true &&
710
- match === 0 /* NO_MATCH */ &&
711
- (matchKind & 4 /* EXCEPTION_MATCH */) === 0 &&
710
+ match === 0 /* Result.NO_MATCH */ &&
711
+ (matchKind & 4 /* Result.EXCEPTION_MATCH */) === 0 &&
712
712
  matchLabels <= label) {
713
713
  match = binSearch(packed, hash, index + 1, index + packed[index] + 1)
714
- ? 8 /* NORMAL_MATCH */ | 2 /* PRIVATE_MATCH */
715
- : 0 /* NO_MATCH */;
714
+ ? 8 /* Result.NORMAL_MATCH */ | 2 /* Result.PRIVATE_MATCH */
715
+ : 0 /* Result.NO_MATCH */;
716
716
  }
717
717
  index += packed[index] + 1;
718
718
  // If we found a match, the longest match that is being tracked for this
@@ -721,14 +721,14 @@ function suffixLookup(hostname, options, out) {
721
721
  // as well as the number of labels contained in this suffix (this is
722
722
  // important to make sure that we always keep the longest match if there
723
723
  // are both a wildcard and a normal rule matching).
724
- if (match !== 0 /* NO_MATCH */) {
724
+ if (match !== 0 /* Result.NO_MATCH */) {
725
725
  matchKind = match;
726
- matchLabels = label + ((match & 16 /* WILDCARD_MATCH */) !== 0 ? 2 : 1);
726
+ matchLabels = label + ((match & 16 /* Result.WILDCARD_MATCH */) !== 0 ? 2 : 1);
727
727
  matchIndex = labelStart;
728
728
  }
729
729
  }
730
- out.isIcann = (matchKind & 1 /* ICANN_MATCH */) !== 0;
731
- out.isPrivate = (matchKind & 2 /* PRIVATE_MATCH */) !== 0;
730
+ out.isIcann = (matchKind & 1 /* Result.ICANN_MATCH */) !== 0;
731
+ out.isPrivate = (matchKind & 2 /* Result.PRIVATE_MATCH */) !== 0;
732
732
  // No match found
733
733
  if (matchIndex === -1) {
734
734
  out.publicSuffix =
@@ -738,14 +738,14 @@ function suffixLookup(hostname, options, out) {
738
738
  // If match is an exception, this means that we need to count less label.
739
739
  // For example, exception rule !foo.com would yield suffix 'com', so we need
740
740
  // to locate the next dot and slice from there.
741
- if ((matchKind & 4 /* EXCEPTION_MATCH */) !== 0) {
741
+ if ((matchKind & 4 /* Result.EXCEPTION_MATCH */) !== 0) {
742
742
  out.publicSuffix = hostname.slice(BUFFER[((matchLabels - 2) << 1) + 1]);
743
743
  return;
744
744
  }
745
745
  // If match is a wildcard, we need to match one more label. If wildcard rule
746
746
  // was *.com, we would have stored only 'com' in the packed structure and we
747
747
  // need to take one extra label on the left.
748
- if ((matchKind & 16 /* WILDCARD_MATCH */) !== 0) {
748
+ if ((matchKind & 16 /* Result.WILDCARD_MATCH */) !== 0) {
749
749
  out.publicSuffix =
750
750
  matchLabels >= numberOfHashes
751
751
  ? hostname
@@ -762,29 +762,29 @@ function suffixLookup(hostname, options, out) {
762
762
  // this un-necessary allocation, we use a global object which is re-used.
763
763
  const RESULT = getEmptyResult();
764
764
  function parse(url, options = {}) {
765
- return parseImpl(url, 5 /* ALL */, suffixLookup, options, getEmptyResult());
765
+ return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, getEmptyResult());
766
766
  }
767
767
  function getHostname(url, options = {}) {
768
768
  /*@__INLINE__*/ resetResult(RESULT);
769
- return parseImpl(url, 0 /* HOSTNAME */, suffixLookup, options, RESULT).hostname;
769
+ return parseImpl(url, 0 /* FLAG.HOSTNAME */, suffixLookup, options, RESULT).hostname;
770
770
  }
771
771
  function getPublicSuffix(url, options = {}) {
772
772
  /*@__INLINE__*/ resetResult(RESULT);
773
- return parseImpl(url, 2 /* PUBLIC_SUFFIX */, suffixLookup, options, RESULT)
773
+ return parseImpl(url, 2 /* FLAG.PUBLIC_SUFFIX */, suffixLookup, options, RESULT)
774
774
  .publicSuffix;
775
775
  }
776
776
  function getDomain(url, options = {}) {
777
777
  /*@__INLINE__*/ resetResult(RESULT);
778
- return parseImpl(url, 3 /* DOMAIN */, suffixLookup, options, RESULT).domain;
778
+ return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
779
779
  }
780
780
  function getSubdomain(url, options = {}) {
781
781
  /*@__INLINE__*/ resetResult(RESULT);
782
- return parseImpl(url, 4 /* SUB_DOMAIN */, suffixLookup, options, RESULT)
782
+ return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
783
783
  .subdomain;
784
784
  }
785
785
  function getDomainWithoutSuffix(url, options = {}) {
786
786
  /*@__INLINE__*/ resetResult(RESULT);
787
- return parseImpl(url, 5 /* ALL */, suffixLookup, options, RESULT)
787
+ return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, RESULT)
788
788
  .domainWithoutSuffix;
789
789
  }
790
790