Perf: use tldts-experimental when possible

This commit is contained in:
SukkaW
2024-05-26 04:32:08 +08:00
parent db6786a0d6
commit 1288460c48
9 changed files with 32 additions and 24 deletions

View File

@@ -1,10 +1,10 @@
import * as tldts from 'tldts';
import { parse as tldtsParse } from 'tldts';
import { isProbablyIpv4 } from './is-fast-ip';
export const normalizeDomain = (domain: string) => {
if (!domain) return null;
if (isProbablyIpv4(domain)) return null;
const parsed = tldts.parse(domain, { allowPrivateDomains: true, detectIp: false });
const parsed = tldtsParse(domain, { allowPrivateDomains: true, detectIp: false });
// if (parsed.isIp) return null;
if (!parsed.hostname) return null;
if (!parsed.isIcann && !parsed.isPrivate) return null;