mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
23 lines
773 B
TypeScript
23 lines
773 B
TypeScript
import type * as tldts from 'tldts';
|
|
|
|
export const looseTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
|
allowPrivateDomains: false,
|
|
extractHostname: false,
|
|
validateHostname: false,
|
|
detectIp: false,
|
|
mixedInputs: false
|
|
};
|
|
|
|
export const loosTldOptWithPrivateDomains: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
|
...looseTldtsOpt,
|
|
allowPrivateDomains: true
|
|
};
|
|
|
|
export const normalizeTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
|
allowPrivateDomains: true,
|
|
// in normalizeDomain, we only care if it contains IP, we don't care if we need to extract it
|
|
// by setting detectIp to false and manually check ip outside tldts.parse, we can skip the tldts
|
|
// inner "extractHostname" call
|
|
detectIp: false
|
|
};
|