tldts 5.7.111 → 6.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.
- package/README.md +63 -54
- package/bin/cli.js +4 -6
- package/dist/cjs/index.js +48 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/data/trie.js +4 -6
- package/dist/cjs/src/data/trie.js.map +1 -1
- package/dist/cjs/src/suffix-trie.js +11 -9
- package/dist/cjs/src/suffix-trie.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/es6/src/data/trie.js +4 -6
- package/dist/es6/src/data/trie.js.map +1 -1
- package/dist/es6/src/suffix-trie.js +11 -9
- package/dist/es6/src/suffix-trie.js.map +1 -1
- package/dist/es6/tsconfig.bundle.tsbuildinfo +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/data/trie.d.ts +3 -6
- package/package.json +9 -12
- package/src/data/trie.ts +5 -11
- package/src/suffix-trie.ts +9 -11
package/src/suffix-trie.ts
CHANGED
|
@@ -30,11 +30,11 @@ function lookupInTrie(
|
|
|
30
30
|
let node: ITrie | undefined = trie;
|
|
31
31
|
while (node !== undefined) {
|
|
32
32
|
// We have a match!
|
|
33
|
-
if ((node
|
|
33
|
+
if ((node[0] & allowedMask) !== 0) {
|
|
34
34
|
result = {
|
|
35
35
|
index: index + 1,
|
|
36
|
-
isIcann: node
|
|
37
|
-
isPrivate: node
|
|
36
|
+
isIcann: node[0] === RULE_TYPE.ICANN,
|
|
37
|
+
isPrivate: node[0] === RULE_TYPE.PRIVATE,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -43,10 +43,8 @@ function lookupInTrie(
|
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const succ: {
|
|
47
|
-
|
|
48
|
-
} = node.succ;
|
|
49
|
-
node = succ && (succ[parts[index]] || succ['*']);
|
|
46
|
+
const succ: { [label: string]: ITrie } = node[1];
|
|
47
|
+
node = succ[parts[index]!] ?? succ['*'];
|
|
50
48
|
index -= 1;
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -61,15 +59,15 @@ export default function suffixLookup(
|
|
|
61
59
|
options: ISuffixLookupOptions,
|
|
62
60
|
out: IPublicSuffix,
|
|
63
61
|
): void {
|
|
64
|
-
if (fastPathLookup(hostname, options, out)
|
|
62
|
+
if (fastPathLookup(hostname, options, out)) {
|
|
65
63
|
return;
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
const hostnameParts = hostname.split('.');
|
|
69
67
|
|
|
70
68
|
const allowedMask =
|
|
71
|
-
(options.allowPrivateDomains
|
|
72
|
-
(options.allowIcannDomains
|
|
69
|
+
(options.allowPrivateDomains ? RULE_TYPE.PRIVATE : 0) |
|
|
70
|
+
(options.allowIcannDomains ? RULE_TYPE.ICANN : 0);
|
|
73
71
|
|
|
74
72
|
// Look for exceptions
|
|
75
73
|
const exceptionMatch = lookupInTrie(
|
|
@@ -106,5 +104,5 @@ export default function suffixLookup(
|
|
|
106
104
|
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
|
|
107
105
|
out.isIcann = false;
|
|
108
106
|
out.isPrivate = false;
|
|
109
|
-
out.publicSuffix = hostnameParts[hostnameParts.length - 1];
|
|
107
|
+
out.publicSuffix = hostnameParts[hostnameParts.length - 1] ?? null;
|
|
110
108
|
}
|