mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 17:50:34 +08:00
Fix: DOMAIN-KEYWORD conversion to AdGuardHome
This commit is contained in:
parent
02b13659bb
commit
2afc37d5ab
@ -6,6 +6,7 @@ import type { SingboxSourceFormat } from '../singbox';
|
||||
import * as tldts from 'tldts-experimental';
|
||||
import { looseTldtsOpt } from '../../constants/loose-tldts-opt';
|
||||
import { fastStringCompare } from '../misc';
|
||||
import escapeStringRegexp from 'escape-string-regexp-node';
|
||||
|
||||
type Preprocessed = string[];
|
||||
|
||||
@ -129,15 +130,16 @@ export class DomainsetOutput extends RuleOutput<Preprocessed> {
|
||||
|
||||
for (const keyword of this.domainKeywords) {
|
||||
// Use regex to match keyword
|
||||
results.push(`/${keyword}/`);
|
||||
results.push(`/${escapeStringRegexp(keyword)}/`);
|
||||
}
|
||||
|
||||
for (const ipGroup of [this.ipcidr, this.ipcidrNoResolve]) {
|
||||
for (const ipcidr of ipGroup) {
|
||||
if (ipcidr.endsWith('/32')) {
|
||||
results.push(`||${ipcidr.slice(0, -3)}`);
|
||||
} else if (ipcidr.endsWith('.0/24')) {
|
||||
/* else if (ipcidr.endsWith('.0/24')) {
|
||||
results.push(`||${ipcidr.slice(0, -6)}.*`);
|
||||
} */
|
||||
} else {
|
||||
results.push(`||${ipcidr}^`);
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
"csv-parse": "^5.6.0",
|
||||
"devalue": "^5.1.1",
|
||||
"dns2": "^2.1.0",
|
||||
"escape-string-regexp-node": "^1.0.2",
|
||||
"fast-cidr-tools": "^0.3.1",
|
||||
"fdir": "^6.4.2",
|
||||
"foxact": "^0.2.41",
|
||||
|
||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -52,6 +52,9 @@ importers:
|
||||
dns2:
|
||||
specifier: ^2.1.0
|
||||
version: 2.1.0
|
||||
escape-string-regexp-node:
|
||||
specifier: ^1.0.2
|
||||
version: 1.0.2
|
||||
fast-cidr-tools:
|
||||
specifier: ^0.3.1
|
||||
version: 0.3.1
|
||||
@ -920,6 +923,9 @@ packages:
|
||||
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
escape-string-regexp-node@1.0.2:
|
||||
resolution: {integrity: sha512-tv6v/7vF8ob7vTNPBHJ6cdRGtb9t6wBZJt6ZWzJ5kDacXa3jplof+mmoXYLuEUtFXWw8xwR2wVbT2c20HvVubA==}
|
||||
|
||||
escape-string-regexp@2.0.0:
|
||||
resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==}
|
||||
engines: {node: '>=8'}
|
||||
@ -2711,6 +2717,8 @@ snapshots:
|
||||
|
||||
escalade@3.2.0: {}
|
||||
|
||||
escape-string-regexp-node@1.0.2: {}
|
||||
|
||||
escape-string-regexp@2.0.0: {}
|
||||
|
||||
escape-string-regexp@4.0.0: {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user