mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Fix: enable domain check for some reject data source
This commit is contained in:
@@ -5,11 +5,14 @@ export const normalizeDomain = (domain: string) => {
|
||||
if (isProbablyIpv4(domain)) return null;
|
||||
|
||||
const parsed = tldts.parse2(domain);
|
||||
if (parsed.isIp) return null;
|
||||
// if (parsed.isIp) return null;
|
||||
if (!parsed.hostname) return null;
|
||||
if (!parsed.isIcann && !parsed.isPrivate) return null;
|
||||
|
||||
const h = parsed.hostname;
|
||||
if (!h) return null;
|
||||
let h = parsed.hostname;
|
||||
if (h[0] === '.') h = h.slice(1);
|
||||
if (h.endsWith('.')) h = h.slice(0, -1);
|
||||
|
||||
return h[0] === '.' ? h.slice(1) : h;
|
||||
if (h) return h;
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user