@adguard/dnr-converter 1.0.0-alpha.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,9 +75,9 @@ import { splitByDelimiterWithEscapeCharacter } from './utils/string.js';
75
75
  * Origin-capturing prefix for path-only transforms.
76
76
  */ const ORIGIN_PREFIX = '^(https?://[^/]+)';
77
77
  /**
78
- * Prefix for patterns that can match anywhere in the path.
78
+ * Prefix for patterns that can match anywhere in the path and query.
79
79
  * Uses a non-greedy match to capture everything before the pattern.
80
- */ const FLOATING_PREFIX = '^(https?://[^?#]*?)';
80
+ */ const FLOATING_PREFIX = '^(https?://[^/]+/[^#]*?)';
81
81
  /**
82
82
  * Origin-capturing prefix for query-targeting transforms.
83
83
  */ const ORIGIN_PREFIX_QUERY = '^(https?://[^?]+)';
@@ -168,13 +168,20 @@ import { splitByDelimiterWithEscapeCharacter } from './utils/string.js';
168
168
  if (workPattern.startsWith('^')) {
169
169
  workPattern = workPattern.substring(1);
170
170
  }
171
- // Check for end-of-string anchor (\$ in filter syntax, which
172
- // becomes $ in regex). When present, we must NOT append the
173
- // remainder-capturing group (.*) after the pattern.
171
+ // Check for end-of-string anchor. It may be written either as `\$`
172
+ // (escaped, because `$` is the modifier separator in AdGuard syntax)
173
+ // or as a bare `$` when the modifier value is the last one in the rule.
174
+ // Both forms mean the same regex end-of-string anchor. When present,
175
+ // we must NOT append the remainder-capturing group `(.*)` after the
176
+ // pattern — otherwise the anchor would end up in the middle of the
177
+ // resulting regex, producing a rule that never matches.
174
178
  let hasEndAnchor = false;
175
179
  if (workPattern.endsWith('\\$')) {
176
180
  hasEndAnchor = true;
177
181
  workPattern = workPattern.substring(0, workPattern.length - 2);
182
+ } else if (workPattern.endsWith('$')) {
183
+ hasEndAnchor = true;
184
+ workPattern = workPattern.substring(0, workPattern.length - 1);
178
185
  }
179
186
  const userGroupCount = countCaptureGroups(workPattern);
180
187
  // Determine if this is a query-targeting pattern
@@ -188,7 +195,7 @@ import { splitByDelimiterWithEscapeCharacter } from './utils/string.js';
188
195
  } else if (isPathAnchored) {
189
196
  prefix = ORIGIN_PREFIX;
190
197
  } else {
191
- // Pattern can match anywhere in the path (floating match)
198
+ // Pattern can match anywhere in the path and query (floating match)
192
199
  prefix = FLOATING_PREFIX;
193
200
  }
194
201
  // Remove leading escaped slash from path pattern for joining
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adguard/dnr-converter",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.1.1",
4
4
  "description": "A converter that transforms adblock-style filtering rules into rules compatible with the Declarative Net Request (DNR) API.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -57,11 +57,11 @@
57
57
  "@adguard/re2-wasm": "1.2.0"
58
58
  },
59
59
  "dependencies": {
60
- "@adguard/scriptlets": "2.4.2",
60
+ "@adguard/scriptlets": "2.5.0",
61
61
  "commander": "^12.1.0",
62
62
  "punycode": "2.3.1",
63
63
  "valibot": "^1.1.0",
64
- "@adguard/agtree": "^4.1.1",
64
+ "@adguard/agtree": "^4.2.1",
65
65
  "@adguard/logger": "^2.0.0"
66
66
  },
67
67
  "devDependencies": {
@@ -96,8 +96,8 @@
96
96
  "tsx": "^4.19.3",
97
97
  "typescript": "^5.7.3",
98
98
  "vitest": "^4.1.5",
99
- "@adguard/eslint-plugin-logger-context": "^1.0.1",
100
- "@adguard/tsurlfilter": "^6.0.0"
99
+ "@adguard/tsurlfilter": "^6.0.2",
100
+ "@adguard/eslint-plugin-logger-context": "^1.0.1"
101
101
  },
102
102
  "scripts": {
103
103
  "lint": "pnpm lint:code && pnpm lint:types && pnpm lint:md",