tldts-experimental 7.4.28 → 7.5.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.
@@ -5,4 +5,4 @@ import { IPublicSuffix, ISuffixLookupOptions } from 'tldts-core';
5
5
  * should be considered. By default, both are.
6
6
  *
7
7
  */
8
- export default function suffixLookup(hostname: string, options: ISuffixLookupOptions, out: IPublicSuffix): void;
8
+ export default function suffixLookup(hostname: string, options: ISuffixLookupOptions, out: IPublicSuffix): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tldts-experimental",
3
- "version": "7.4.28",
3
+ "version": "7.5.1",
4
4
  "description": "Library to work against complex domain names, subdomains and URIs.",
5
5
  "author": {
6
6
  "name": "Rémi Berson"
@@ -61,11 +61,11 @@
61
61
  "rimraf": "^6.1.2",
62
62
  "rollup": "^4.63.4",
63
63
  "rollup-plugin-sourcemaps2": "^0.5.8",
64
- "tldts-tests": "^7.4.28",
64
+ "tldts-tests": "^7.5.1",
65
65
  "typescript": "^6.0.3"
66
66
  },
67
67
  "dependencies": {
68
- "tldts-core": "^7.4.28"
68
+ "tldts-core": "^7.5.1"
69
69
  },
70
70
  "keywords": [
71
71
  "tld",
@@ -82,5 +82,5 @@
82
82
  "url parsing",
83
83
  "typescript"
84
84
  ],
85
- "gitHead": "0136955ee4b27aecba5aeb1bd2a01501801801ed"
85
+ "gitHead": "53e0057d69985c6217e4518a3e915bd223044e66"
86
86
  }
@@ -103,9 +103,9 @@ export default function suffixLookup(
103
103
  hostname: string,
104
104
  options: ISuffixLookupOptions,
105
105
  out: IPublicSuffix,
106
- ): void {
106
+ ): boolean {
107
107
  if (fastPathLookup(hostname, options, out)) {
108
- return;
108
+ return false;
109
109
  }
110
110
 
111
111
  const { allowIcannDomains, allowPrivateDomains } = options;
@@ -231,6 +231,14 @@ export default function suffixLookup(
231
231
  // important to make sure that we always keep the longest match if there
232
232
  // are both a wildcard and a normal rule matching).
233
233
  if (match !== Result.NO_MATCH) {
234
+ // '*' never matches an empty label ('.S', '..S'): `*.S` then only
235
+ // implies `S`.
236
+ if (
237
+ (match & Result.WILDCARD_MATCH) !== 0 &&
238
+ (labelStart === 1 || hostname.charCodeAt(labelStart - 2) === 46)
239
+ ) {
240
+ match = (match & ~Result.WILDCARD_MATCH) | Result.NORMAL_MATCH;
241
+ }
234
242
  matchKind = match;
235
243
  matchLabels = label + ((match & Result.WILDCARD_MATCH) !== 0 ? 2 : 1);
236
244
  matchIndex = labelStart;
@@ -244,7 +252,7 @@ export default function suffixLookup(
244
252
  if (matchIndex === -1) {
245
253
  out.publicSuffix =
246
254
  numberOfHashes === 1 ? hostname : hostname.slice(BUFFER[1]);
247
- return;
255
+ return false;
248
256
  }
249
257
 
250
258
  // If match is an exception, this means that we need to count less label.
@@ -252,7 +260,7 @@ export default function suffixLookup(
252
260
  // to locate the next dot and slice from there.
253
261
  if ((matchKind & Result.EXCEPTION_MATCH) !== 0) {
254
262
  out.publicSuffix = hostname.slice(BUFFER[((matchLabels - 2) << 1) + 1]);
255
- return;
263
+ return true;
256
264
  }
257
265
 
258
266
  // If match is a wildcard, we need to match one more label. If wildcard rule
@@ -261,7 +269,7 @@ export default function suffixLookup(
261
269
  if ((matchKind & Result.WILDCARD_MATCH) !== 0) {
262
270
  if (matchLabels < numberOfHashes) {
263
271
  out.publicSuffix = hostname.slice(BUFFER[((matchLabels - 1) << 1) + 1]);
264
- return;
272
+ return false;
265
273
  }
266
274
 
267
275
  // matchLabels >= numberOfHashes: the suffix may extend past the labels we
@@ -280,10 +288,11 @@ export default function suffixLookup(
280
288
  }
281
289
  }
282
290
  out.publicSuffix = hostname.slice(suffixStart);
283
- return;
291
+ return false;
284
292
  }
285
293
 
286
294
  // if ((matchKind & Result.NORMAL_MATCH) !== 0)
287
295
  // For normal match, we just slice the hostname at the beginning of suffix.
288
296
  out.publicSuffix = hostname.slice(matchIndex);
297
+ return false;
289
298
  }