tldts-experimental 6.0.0 → 6.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.
package/dist/cjs/index.js CHANGED
@@ -752,10 +752,15 @@ function suffixLookup(hostname, options, out) {
752
752
  // was *.com, we would have stored only 'com' in the packed structure and we
753
753
  // need to take one extra label on the left.
754
754
  if ((matchKind & 16 /* Result.WILDCARD_MATCH */) !== 0) {
755
- out.publicSuffix =
756
- matchLabels >= numberOfHashes
757
- ? hostname
758
- : hostname.slice(BUFFER[((matchLabels - 1) << 1) + 1]);
755
+ if (matchLabels < numberOfHashes) {
756
+ out.publicSuffix = hostname.slice(BUFFER[((matchLabels - 1) << 1) + 1]);
757
+ return;
758
+ }
759
+ const parts = hostname.split('.');
760
+ while (parts.length > matchLabels) {
761
+ parts.shift();
762
+ }
763
+ out.publicSuffix = parts.join('.');
759
764
  return;
760
765
  }
761
766
  // if ((matchKind & Result.NORMAL_MATCH) !== 0)