tldts-icann 7.5.0 → 7.5.2
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 +12 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/suffix-trie.js +3 -2
- package/dist/cjs/src/suffix-trie.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/es6/src/suffix-trie.js +3 -2
- 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/package.json +4 -4
- package/src/suffix-trie.ts +3 -2
package/dist/cjs/index.js
CHANGED
|
@@ -823,9 +823,9 @@ function extraSuffixLookup(hostname, options, isException, out) {
|
|
|
823
823
|
}
|
|
824
824
|
continue;
|
|
825
825
|
}
|
|
826
|
-
// `*.p` also matches `p`, else one more
|
|
827
|
-
if (wildcard && start !==
|
|
828
|
-
start =
|
|
826
|
+
// `*.p` also matches `p`, else one more non-empty label.
|
|
827
|
+
if (wildcard && start > 1 && hostname.charCodeAt(start - 2) !== 46) {
|
|
828
|
+
start = hostname.lastIndexOf('.', start - 2) + 1;
|
|
829
829
|
}
|
|
830
830
|
if (start < rule) {
|
|
831
831
|
rule = start;
|
|
@@ -939,7 +939,12 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
|
|
|
939
939
|
// extractHostname returned `url` unchanged (same reference).
|
|
940
940
|
let urlIsValid = false;
|
|
941
941
|
if (!options.extractHostname) {
|
|
942
|
-
|
|
942
|
+
// Trim trailing dots as extractHostname does (`new URL()` keeps them).
|
|
943
|
+
let end = url.length;
|
|
944
|
+
while (end > 1 && url.charCodeAt(end - 1) === 46 /* '.' */) {
|
|
945
|
+
end -= 1;
|
|
946
|
+
}
|
|
947
|
+
result.hostname = end === url.length ? url : url.slice(0, end);
|
|
943
948
|
}
|
|
944
949
|
else if (options.mixedInputs) {
|
|
945
950
|
urlIsValid = isValidHostname(url);
|
|
@@ -1171,6 +1176,7 @@ function findEdge(node, hash, hostname, start, length) {
|
|
|
1171
1176
|
* Walk `hostname`'s labels right-to-left from `root`, recording the deepest
|
|
1172
1177
|
* ICANN node (with the label boundaries of that match in
|
|
1173
1178
|
* `matchStart`/`matchEnd`). Returns whether any match was found.
|
|
1179
|
+
* An empty label (leading dot or `..`) never matches a `*` edge.
|
|
1174
1180
|
*/
|
|
1175
1181
|
function walk(hostname, root) {
|
|
1176
1182
|
let node = root;
|
|
@@ -1182,7 +1188,7 @@ function walk(hostname, root) {
|
|
|
1182
1188
|
if (code === 46 /* '.' */) {
|
|
1183
1189
|
const start = i + 1;
|
|
1184
1190
|
let edge = findEdge(node, hash >>> 0, hostname, start, end - start);
|
|
1185
|
-
if (edge === -1) {
|
|
1191
|
+
if (edge === -1 && end !== start) {
|
|
1186
1192
|
edge = wildcardEdge[node];
|
|
1187
1193
|
}
|
|
1188
1194
|
if (edge === -1) {
|
|
@@ -1205,7 +1211,7 @@ function walk(hostname, root) {
|
|
|
1205
1211
|
// duplicated rather than folded into the loop (via `i >= -1`) because that
|
|
1206
1212
|
// extra per-character branch measured slightly slower on the hot path.
|
|
1207
1213
|
let edge = findEdge(node, hash >>> 0, hostname, 0, end);
|
|
1208
|
-
if (edge === -1) {
|
|
1214
|
+
if (edge === -1 && end !== 0) {
|
|
1209
1215
|
edge = wildcardEdge[node];
|
|
1210
1216
|
}
|
|
1211
1217
|
if (edge !== -1) {
|