Skip to content

Commit 2afc37d

Browse files
committed
Fix: DOMAIN-KEYWORD conversion to AdGuardHome
1 parent 02b1365 commit 2afc37d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Build/lib/rules/domainset.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { SingboxSourceFormat } from '../singbox';
66
import * as tldts from 'tldts-experimental';
77
import { looseTldtsOpt } from '../../constants/loose-tldts-opt';
88
import { fastStringCompare } from '../misc';
9+
import escapeStringRegexp from 'escape-string-regexp-node';
910

1011
type Preprocessed = string[];
1112

@@ -129,15 +130,16 @@ export class DomainsetOutput extends RuleOutput<Preprocessed> {
129130

130131
for (const keyword of this.domainKeywords) {
131132
// Use regex to match keyword
132-
results.push(`/${keyword}/`);
133+
results.push(`/${escapeStringRegexp(keyword)}/`);
133134
}
134135

135136
for (const ipGroup of [this.ipcidr, this.ipcidrNoResolve]) {
136137
for (const ipcidr of ipGroup) {
137138
if (ipcidr.endsWith('/32')) {
138139
results.push(`||${ipcidr.slice(0, -3)}`);
139-
} else if (ipcidr.endsWith('.0/24')) {
140-
results.push(`||${ipcidr.slice(0, -6)}.*`);
140+
/* else if (ipcidr.endsWith('.0/24')) {
141+
results.push(`||${ipcidr.slice(0, -6)}.*`);
142+
} */
141143
} else {
142144
results.push(`||${ipcidr}^`);
143145
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"csv-parse": "^5.6.0",
3333
"devalue": "^5.1.1",
3434
"dns2": "^2.1.0",
35+
"escape-string-regexp-node": "^1.0.2",
3536
"fast-cidr-tools": "^0.3.1",
3637
"fdir": "^6.4.2",
3738
"foxact": "^0.2.41",

pnpm-lock.yaml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)