mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 03:32:36 +08:00
fix(#1335): support cidr
This commit is contained in:
parent
af0cd4a342
commit
1a6f842492
|
@ -34,17 +34,22 @@ const domain_tld_part = String.raw`(?:\w{2,64}\*?|\*)`;
|
|||
const rDomainSimple = domain_subdomain_part + domain_tld_part;
|
||||
|
||||
const ipv4_part = String.raw`\d{1,3}`;
|
||||
// 127.0.0.1 (full ipv4)
|
||||
const rIPv4 = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
|
||||
// const rIPv4Partial = String.raw`${ipv4_part}\.(?:(?:${ipv4_part}|\*)\.){0,2}\.\*`;
|
||||
|
||||
const ipv6_part = "(?:[a-fA-F0-9:])+";
|
||||
const rIPv6 = `(?:${ipv6_part}:+)+${ipv6_part}`;
|
||||
|
||||
const rLocal = `localhost|<local>|localdomain`;
|
||||
const rValidPart = `${rDomainSimple}|${rIPv4}|${rIPv6}|${rLocal}`;
|
||||
|
||||
const getValidReg = (isWindows: boolean) => {
|
||||
// 127.0.0.1 (full ipv4)
|
||||
const rIPv4Unix = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}(?:\/\d{1,2})?`;
|
||||
const rIPv4Windows = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
|
||||
|
||||
const rIPv6Unix = String.raw`(?:${ipv6_part}:+)+${ipv6_part}(?:\/\d{1,3})?`;
|
||||
const rIPv6Windows = String.raw`(?:${ipv6_part}:+)+${ipv6_part}`;
|
||||
|
||||
const rValidPart = `${rDomainSimple}|${
|
||||
isWindows ? rIPv4Windows : rIPv4Unix
|
||||
}|${isWindows ? rIPv6Windows : rIPv6Unix}|${rLocal}`;
|
||||
const separator = isWindows ? ";" : ",";
|
||||
const rValid = String.raw`^(${rValidPart})(?:${separator}\s?(${rValidPart}))*${separator}?$`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user