mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Perf: make normalizeDomain faster
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type * as tldts from 'tldts';
|
||||
|
||||
export const looseTldtsOpt: Parameters<typeof tldts.getSubdomain>[1] = {
|
||||
export const looseTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
||||
allowPrivateDomains: false,
|
||||
extractHostname: false,
|
||||
validateHostname: false,
|
||||
@@ -8,12 +8,15 @@ export const looseTldtsOpt: Parameters<typeof tldts.getSubdomain>[1] = {
|
||||
mixedInputs: false
|
||||
};
|
||||
|
||||
export const loosTldOptWithPrivateDomains: Parameters<typeof tldts.getSubdomain>[1] = {
|
||||
export const loosTldOptWithPrivateDomains: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
||||
...looseTldtsOpt,
|
||||
allowPrivateDomains: true
|
||||
};
|
||||
|
||||
export const normalizeTldtsOpt: Parameters<typeof tldts.getSubdomain>[1] = {
|
||||
export const normalizeTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
|
||||
allowPrivateDomains: true,
|
||||
detectIp: 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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user