|
@@ -8,7 +8,7 @@ import { noop } from 'foxts/noop';
|
|
|
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
|
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
|
|
|
|
|
|
|
import { deleteBit, getBit, missingBit, setBit } from 'foxts/bitwise';
|
|
import { deleteBit, getBit, missingBit, setBit } from 'foxts/bitwise';
|
|
|
-import { toASCII } from 'punycode/';
|
|
|
|
|
|
|
+import { domainToASCII } from 'node:url';
|
|
|
|
|
|
|
|
const START = 1 << 1;
|
|
const START = 1 << 1;
|
|
|
const INCLUDE_ALL_SUBDOMAIN = 1 << 2;
|
|
const INCLUDE_ALL_SUBDOMAIN = 1 << 2;
|
|
@@ -320,13 +320,13 @@ abstract class Triebase<Meta = unknown> {
|
|
|
|
|
|
|
|
const onMatches = subdomainOnly
|
|
const onMatches = subdomainOnly
|
|
|
? (suffix: string[], subdomain: boolean) => { // fast path (default option)
|
|
? (suffix: string[], subdomain: boolean) => { // fast path (default option)
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
if (!subdomain && subStringEqual(inputSuffix, d, 1)) return;
|
|
if (!subdomain && subStringEqual(inputSuffix, d, 1)) return;
|
|
|
|
|
|
|
|
results.push(subdomain ? '.' + d : d);
|
|
results.push(subdomain ? '.' + d : d);
|
|
|
}
|
|
}
|
|
|
: (suffix: string[], subdomain: boolean) => { // fast path (default option)
|
|
: (suffix: string[], subdomain: boolean) => { // fast path (default option)
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
results.push(subdomain ? '.' + d : d);
|
|
results.push(subdomain ? '.' + d : d);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -380,7 +380,7 @@ abstract class Triebase<Meta = unknown> {
|
|
|
|
|
|
|
|
public dumpWithoutDot(onSuffix: (suffix: string, subdomain: boolean) => void, withSort = false) {
|
|
public dumpWithoutDot(onSuffix: (suffix: string, subdomain: boolean) => void, withSort = false) {
|
|
|
const handleSuffix = (suffix: string[], subdomain: boolean) => {
|
|
const handleSuffix = (suffix: string[], subdomain: boolean) => {
|
|
|
- onSuffix(toASCII(fastStringArrayJoin(suffix, '.')), subdomain);
|
|
|
|
|
|
|
+ onSuffix(domainToASCII(fastStringArrayJoin(suffix, '.')), subdomain);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.walk(handleSuffix, withSort);
|
|
this.walk(handleSuffix, withSort);
|
|
@@ -393,11 +393,11 @@ abstract class Triebase<Meta = unknown> {
|
|
|
|
|
|
|
|
const handleSuffix = onSuffix
|
|
const handleSuffix = onSuffix
|
|
|
? (suffix: string[], subdomain: boolean) => {
|
|
? (suffix: string[], subdomain: boolean) => {
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
onSuffix(subdomain ? '.' + d : d);
|
|
onSuffix(subdomain ? '.' + d : d);
|
|
|
}
|
|
}
|
|
|
: (suffix: string[], subdomain: boolean) => {
|
|
: (suffix: string[], subdomain: boolean) => {
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
results.push(subdomain ? '.' + d : d);
|
|
results.push(subdomain ? '.' + d : d);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -427,11 +427,11 @@ abstract class Triebase<Meta = unknown> {
|
|
|
|
|
|
|
|
const handleSuffix = onSuffix
|
|
const handleSuffix = onSuffix
|
|
|
? (suffix: string[], subdomain: boolean, meta: Meta | undefined) => {
|
|
? (suffix: string[], subdomain: boolean, meta: Meta | undefined) => {
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
return onSuffix(subdomain ? '.' + d : d, meta);
|
|
return onSuffix(subdomain ? '.' + d : d, meta);
|
|
|
}
|
|
}
|
|
|
: (suffix: string[], subdomain: boolean, meta: Meta | undefined) => {
|
|
: (suffix: string[], subdomain: boolean, meta: Meta | undefined) => {
|
|
|
- const d = toASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
|
|
|
|
+ const d = domainToASCII(fastStringArrayJoin(suffix, '.'));
|
|
|
results.push([subdomain ? '.' + d : d, meta]);
|
|
results.push([subdomain ? '.' + d : d, meta]);
|
|
|
};
|
|
};
|
|
|
|
|
|