Drop gorhill publicsuffixlist

This commit is contained in:
SukkaW
2024-08-02 17:02:41 +08:00
parent ba66abe750
commit 3d3abb8b50
8 changed files with 12 additions and 103 deletions

View File

@@ -5,12 +5,10 @@ import { bench, group, run } from 'mitata';
import * as tldts from 'tldts';
import * as tldtsExperimental from 'tldts-experimental';
import { getGorhillPublicSuffixPromise } from './get-gorhill-publicsuffix';
(async () => {
const data = await processLineFromReadline(await fetchRemoteTextByLine('https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt'));
const gorhill = await getGorhillPublicSuffixPromise();
const tldtsOpt: Parameters<typeof tldts.getDomain>[1] = {
allowPrivateDomains: false,
extractHostname: false,
@@ -21,18 +19,6 @@ import { getGorhillPublicSuffixPromise } from './get-gorhill-publicsuffix';
(['getDomain', 'getPublicSuffix', 'getSubdomain', 'parse'] as const).forEach(methodName => {
group(methodName, () => {
if (methodName in gorhill) {
bench('gorhill', () => {
for (let i = 0, len = data.length; i < len; i++) {
const line = data[i];
const safeGorhillLine = line[0] === '.' ? line.slice(1) : line;
// @ts-expect-error -- type guarded
gorhill[methodName](safeGorhillLine);
}
});
}
bench('tldts', () => {
for (let i = 0, len = data.length; i < len; i++) {
tldts[methodName](data[i], tldtsOpt);