Browse Source

Remove tldts cache

SukkaW 2 years ago
parent
commit
333e2054d9
2 changed files with 2 additions and 15 deletions
  1. 0 13
      Build/lib/cached-tld-parse.ts
  2. 2 2
      Build/lib/normalize-domain.ts

+ 0 - 13
Build/lib/cached-tld-parse.ts

@@ -1,19 +1,6 @@
-import * as tldts from 'tldts';
 import { createCache } from './cache-apply';
 import type { PublicSuffixList } from '@gorhill/publicsuffixlist';
 
-const cache = createCache('cached-tld-parse', true);
-const cache2 = createCache('cached-tld-parse2', true);
-
-const sharedConfig = { allowPrivateDomains: true };
-const sharedConfig2 = { allowPrivateDomains: true, detectIp: false };
-
-/** { allowPrivateDomains: true } */
-export const parse = (domain: string) => cache.sync(domain, () => tldts.parse(domain, sharedConfig));
-/** { allowPrivateDomains: true, detectIp: false } */
-export const parse2 = (domain: string) => cache2.sync(domain, () => tldts.parse(domain, sharedConfig2));
-export const parseWithoutDetectIp = parse2;
-
 let gothillGetDomainCache: ReturnType<typeof createCache> | null = null;
 export const createCachedGorhillGetDomain = (gorhill: PublicSuffixList) => {
   gothillGetDomainCache ??= createCache('cached-gorhill-get-domain', true);

+ 2 - 2
Build/lib/normalize-domain.ts

@@ -1,10 +1,10 @@
-import * as tldts from './cached-tld-parse';
+import * as tldts 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.parse2(domain);
+  const parsed = tldts.parse(domain, { allowPrivateDomains: true, detectIp: false });
   // if (parsed.isIp) return null;
   if (!parsed.hostname) return null;
   if (!parsed.isIcann && !parsed.isPrivate) return null;