@url-sanitize/brave 2.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Antonio Orionus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ This package bundles Brave Debouncer data from:
2
+
3
+ https://github.com/brave/adblock-lists
4
+
5
+ The bundled data is licensed MPL-2.0 by its upstream maintainers.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @url-sanitize/brave
2
+
3
+ Brave Debouncer catalog and adapter for [`@url-sanitize/core`](../core).
4
+
5
+ Ships a pinned snapshot of:
6
+
7
+ ```text
8
+ https://raw.githubusercontent.com/brave/adblock-lists/master/brave-lists/debounce.json
9
+ ```
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install @url-sanitize/core @url-sanitize/brave
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { compileSanitizer } from '@url-sanitize/core';
21
+ import { braveCatalog } from '@url-sanitize/brave';
22
+
23
+ const sanitize = compileSanitizer(braveCatalog);
24
+ sanitize('https://y2u.be/dQw4w9WgXcQ');
25
+ ```
26
+
27
+ ## Raw access
28
+
29
+ ```ts
30
+ import { braveRawData, braveMetadata } from '@url-sanitize/brave/raw';
31
+ import { braveToCatalog } from '@url-sanitize/brave/adapter';
32
+ ```
33
+
34
+ ## License
35
+
36
+ Adapter code is project code. Bundled Brave Debouncer data is **MPL-2.0**.
37
+ See [NOTICE](NOTICE).
package/data/data.json ADDED
@@ -0,0 +1,532 @@
1
+ [
2
+ {
3
+ "include": [
4
+ "*://lcmspubcontact.lc.ca.gov/PublicLCMS/LinkTracking.php?*",
5
+ "*://cc.zdnet.com/v1/otc/*",
6
+ "*://cc.cnet.com/v1/otc/*",
7
+ "*://cc.mashable.com/v1/*",
8
+ "*://howl.me/link/?*",
9
+ "*://www.pntrac.com/t/*",
10
+ "*://track.flexlinks.com/a.ashx?*",
11
+ "*://www.wordseed.com/go/*",
12
+ "*://visit.ws/visit/*",
13
+ "*://laylo.co/e/*",
14
+ "*://llo.to/e/*",
15
+ "*://g-o-media.digidip.net/visit?*",
16
+ "*://www.dpbolvw.net/click-*",
17
+ "*://www.tkqlhce.com/click-",
18
+ "*://backerkit.com/ahoy/messages/*/click?*",
19
+ "*://www.sopasti.com/anime.php?*",
20
+ "*://flake.creditcable.info/*",
21
+ "*://www.forocoches.com/link.php?*",
22
+ "*://mcpedl.com/leaving/?*",
23
+ "*://track.effiliation.com/servlet/effi.redir*",
24
+ "*://go.skimresources.com/*",
25
+ "*://shop-links.co/link*",
26
+ "*://www.jdoqocy.com/click-*",
27
+ "*://www.kqzyfj.com/click-*",
28
+ "*://www.pjtra.com/t/*",
29
+ "*://*.narrativ.com/api/v0/client_redirect/*",
30
+ "*://c.pepperjamnetwork.com/click*",
31
+ "*://*.avantlink.com/click.php?*",
32
+ "*://*.pjatr.com/t/*",
33
+ "*://www.pntrs.com/t/*",
34
+ "*://*.nordstrom.com/Linkshare?*",
35
+ "*://pj.nutribullet.com/t/*",
36
+ "*://www.gopjn.com/t/*",
37
+ "*://pvn.mediamarkt.de/trck/eclick/*",
38
+ "*://pvn.saturn.de/trck/eclick/*",
39
+ "*://api.bam-x.com/api/v1/clickmate/*",
40
+ "*://go.redirectingat.com/*",
41
+ "*://x.chip.de/linktrack/button/*",
42
+ "*://*.mailchimp.com/mctx/clicks?*",
43
+ "*://*.tradedoubler.com/click?*",
44
+ "*://cc.techbargains.com/v1/otc/*",
45
+ "*://www.anrdoezrs.net/click-*"
46
+ ],
47
+ "exclude": [],
48
+ "action": "redirect",
49
+ "param": "url"
50
+ },
51
+ {
52
+ "include": [
53
+ "*://t.cfjump.com/*"
54
+ ],
55
+ "exclude": [],
56
+ "action": "redirect",
57
+ "param": "Url"
58
+ },
59
+ {
60
+ "include": [
61
+ "*://trk.pmsrv.co/v2/trk?*",
62
+ "*://trk.pm-srv.co/v2/trk?*"
63
+ ],
64
+ "exclude": [],
65
+ "action": "redirect",
66
+ "param": "rurl"
67
+ },
68
+ {
69
+ "include": [
70
+ "*://app.hive.co/email/elt/*"
71
+ ],
72
+ "exclude": [],
73
+ "action": "redirect",
74
+ "param": "next"
75
+ },
76
+ {
77
+ "include": [
78
+ "*://redir.tradedoubler.com/*"
79
+ ],
80
+ "exclude": [],
81
+ "action": "redirect",
82
+ "param": "_td_deeplink"
83
+ },
84
+ {
85
+ "include": [
86
+ "*://clicks.trx-hub.com/xid/*"
87
+ ],
88
+ "exclude": [],
89
+ "action": "redirect",
90
+ "param": "q"
91
+ },
92
+ {
93
+ "include": [
94
+ "*://www.zenaps.com/rclick.php*"
95
+ ],
96
+ "exclude": [],
97
+ "action": "redirect",
98
+ "param": "pr"
99
+ },
100
+ {
101
+ "include": [
102
+ "*://www.clixgalore.com/Lead.aspx*"
103
+ ],
104
+ "exclude": [],
105
+ "prepend_scheme": "http",
106
+ "action": "redirect",
107
+ "param": "AffDirectURL"
108
+ },
109
+ {
110
+ "include": [
111
+ "*://www.clixgalore.com/Lead.aspx*"
112
+ ],
113
+ "exclude": [],
114
+ "prepend_scheme": "http",
115
+ "action": "redirect",
116
+ "param": "LP"
117
+ },
118
+ {
119
+ "include": [
120
+ "*://rd.bizrate.com/rd2?*",
121
+ "*://rd.connexity.net/rd?*",
122
+ "*://rd.bizrate.com/rd?*"
123
+ ],
124
+ "exclude": [],
125
+ "action": "redirect",
126
+ "param": "t"
127
+ },
128
+ {
129
+ "include": [
130
+ "*://ad.atdmt.com/s/go;*"
131
+ ],
132
+ "exclude": [],
133
+ "action": "redirect",
134
+ "param": "h"
135
+ },
136
+ {
137
+ "include": [
138
+ "*://*.demdex.net/*"
139
+ ],
140
+ "exclude": [],
141
+ "action": "redirect",
142
+ "param": "d_rd"
143
+ },
144
+ {
145
+ "include": [
146
+ "*://www.awin1.com/cread.php?*"
147
+ ],
148
+ "exclude": [],
149
+ "action": "redirect",
150
+ "param": "ued"
151
+ },
152
+ {
153
+ "include": [
154
+ "*://www.awin1.com/cread.php?*",
155
+ "*://www.awin1.com/awclick.php?*"
156
+ ],
157
+ "exclude": [],
158
+ "action": "redirect",
159
+ "param": "p"
160
+ },
161
+ {
162
+ "include": [
163
+ "*://search.app/?*",
164
+ "*://*.getprice.com.au/prodhits.aspx?*"
165
+ ],
166
+ "exclude": [],
167
+ "action": "redirect",
168
+ "param": "link"
169
+ },
170
+ {
171
+ "include": [
172
+ "*://www.shareasale.com/r.cfm?*",
173
+ "*://shareasale.com/r.cfm?*",
174
+ "*://www.shareasale-analytics.com/r.cfm?*",
175
+ "*://shareasale-analytics.com/r.cfm?*"
176
+ ],
177
+ "exclude": [],
178
+ "prepend_scheme": "https",
179
+ "action": "redirect",
180
+ "param": "urllink"
181
+ },
182
+ {
183
+ "include": [
184
+ "*://click.icptrack.com/icp/relay.php*"
185
+ ],
186
+ "exclude": [],
187
+ "action": "redirect",
188
+ "param": "destination"
189
+ },
190
+ {
191
+ "include": [
192
+ "*://t.lever-analytics.com/email-link?",
193
+ "*://cat.criteo.com/beacon?*"
194
+ ],
195
+ "exclude": [],
196
+ "action": "redirect",
197
+ "param": "dest"
198
+ },
199
+ {
200
+ "include": [
201
+ "*://c212.net/c/link/?*",
202
+ "*://*.c9ftyd.net/c/*",
203
+ "*://*.iyhh.net/c/*",
204
+ "*://*.glg9ob.net/c/*",
205
+ "*://*.evyy.net/c/*",
206
+ "*://*.uikc.net/c/*",
207
+ "*://*.ztk5.net/*",
208
+ "*://*.rg35.net/*",
209
+ "*://sherlock.scribblelive.com/r?*",
210
+ "*://*.engage.squarespace-mail.com/r?*",
211
+ "*://engage.squarespace-mail.com/r?*",
212
+ "*://goto.target.com/c/*",
213
+ "*://goto.walmart.com/c/*",
214
+ "*://*.sjv.io/c/*",
215
+ "*://*.8ocm68.net/c/*",
216
+ "*://*.xovt.net/c/*",
217
+ "*://*.i114863.net/c/*",
218
+ "*://*.58dp.net/c/*",
219
+ "*://*.pxf.io/c/*",
220
+ "*://*.7tiv.net/c/*",
221
+ "*://*.5ad6.net/c/*",
222
+ "*://*.q77h.net/c/*",
223
+ "*://*.3uu8.net/c/*",
224
+ "*://*.uxsi.net/c/*",
225
+ "*://*.njih.net/c/*",
226
+ "*://*.pdy5.net/c/*",
227
+ "*://*.igs4ds.net/c/*",
228
+ "*://*.mvvx.net/c/*",
229
+ "*://*.xwrk.net/c/*",
230
+ "*://*.fziv.net/c/*",
231
+ "*://*.lvuv.net/c/*",
232
+ "*://*.xibx.net/c/*",
233
+ "*://*.attfm2.net/c/*",
234
+ "*://*.tkjf.net/c/*",
235
+ "*://deeplink-bh.datafeedfile.com/sl/*",
236
+ "*://deeplink-bh.datafeedfile.com/sl?*",
237
+ "*://*.a9yw.net/c/*",
238
+ "*://*.pfm4.net/c/*",
239
+ "*://*.i254217.net/c/*",
240
+ "*://*.i182465.net/c/*",
241
+ "*://*.vthnbx.net/c/*",
242
+ "*://*.ryvx.net/c/*",
243
+ "*://*.7eer.net/c/*",
244
+ "*://microsoft.msafflnk.net/c/*",
245
+ "*://*.i312864.net/c/*",
246
+ "*://*.tmfhgn.net/c/*",
247
+ "*://*.obak77.net/c/*",
248
+ "*://*.yvzx.net/c/*",
249
+ "*://goto.carters.com/c/*",
250
+ "*://*.ioym.net/c/*",
251
+ "*://*.ntaf.net/c/*",
252
+ "*://*.zlwlj8.net/c/*",
253
+ "*://*.uvwgb9.net/c/*",
254
+ "*://*.3anx.net/c/*",
255
+ "*://*.rrmo.net/c/*",
256
+ "*://*.i308314.net/c/*",
257
+ "*://*.uqhv.net/c/*",
258
+ "*://*.vzew.net/c/*",
259
+ "*://*.qflm.net/c/*",
260
+ "*://*.rfvk.net/c/*",
261
+ "*://redirect.viglink.com/*",
262
+ "*://*.am3t9s.net/*"
263
+ ],
264
+ "exclude": [],
265
+ "action": "redirect",
266
+ "param": "u"
267
+ },
268
+ {
269
+ "include": [
270
+ "*://ck.jp.ap.valuecommerce.com/servlet/referral?*",
271
+ "*://atrrd.valuecommerce.com/resolve/*",
272
+ "*://*.valuecommerce.ne.jp/cgi-bin/*"
273
+ ],
274
+ "exclude": [],
275
+ "action": "redirect",
276
+ "param": "vc_url"
277
+ },
278
+ {
279
+ "include": [
280
+ "*://target.georiot.com/*"
281
+ ],
282
+ "exclude": [],
283
+ "action": "redirect",
284
+ "param": "GR_URL"
285
+ },
286
+ {
287
+ "include": [
288
+ "*://click.linksynergy.com/deeplink*"
289
+ ],
290
+ "exclude": [],
291
+ "action": "redirect",
292
+ "param": "murl"
293
+ },
294
+ {
295
+ "include": [
296
+ "*://*.ouo.today/*"
297
+ ],
298
+ "exclude": [],
299
+ "action": "base64,redirect",
300
+ "param": "cr"
301
+ },
302
+ {
303
+ "include": [
304
+ "*://www.ojrq.net/p/*"
305
+ ],
306
+ "exclude": [],
307
+ "action": "redirect",
308
+ "param": "return"
309
+ },
310
+ {
311
+ "include": [
312
+ "*://d.agkn.com/pixel/*"
313
+ ],
314
+ "exclude": [],
315
+ "action": "redirect",
316
+ "param": "l1"
317
+ },
318
+ {
319
+ "include": [
320
+ "*://t.mailpgn.com/l/*"
321
+ ],
322
+ "exclude": [],
323
+ "action": "redirect",
324
+ "param": "fl"
325
+ },
326
+ {
327
+ "include": [
328
+ "*://jsv3.recruitics.com/redirect?*"
329
+ ],
330
+ "exclude": [],
331
+ "action": "redirect",
332
+ "param": "rx_url"
333
+ },
334
+ {
335
+ "include": [
336
+ "*://app.adjust.com/*"
337
+ ],
338
+ "exclude": [],
339
+ "action": "redirect",
340
+ "param": "redirect"
341
+ },
342
+ {
343
+ "include": [
344
+ "*://pvn.mediamarkt.de/trck/eclick/*"
345
+ ],
346
+ "exclude": [],
347
+ "action": "base64,redirect",
348
+ "param": "url64fb"
349
+ },
350
+ {
351
+ "include": [
352
+ "*://www.googleadservices.com/pagead/aclk?*"
353
+ ],
354
+ "exclude": [],
355
+ "action": "redirect",
356
+ "param": "adurl"
357
+ },
358
+ {
359
+ "include": [
360
+ "*://*.lt.acemlna.com/Prod/link-tracker?*",
361
+ "*://*.lt.acemlnb.com/Prod/link-tracker?*",
362
+ "*://*.lt.acemlnc.com/Prod/link-tracker?*",
363
+ "*://*.lt.acemlnd.com/Prod/link-tracker?*",
364
+ "*://*.lt.emlnk.com/Prod/link-tracker?*",
365
+ "*://*.lt.emlnk1.com/Prod/link-tracker?*",
366
+ "*://*.lt.emlnk2.com/Prod/link-tracker?*",
367
+ "*://*.lt.emlnk3.com/Prod/link-tracker?*",
368
+ "*://*.lt.emlnk4.com/Prod/link-tracker?*",
369
+ "*://*.lt.emlnk5.com/Prod/link-tracker?*",
370
+ "*://*.lt.emlnk6.com/Prod/link-tracker?*",
371
+ "*://*.lt.emlnk7.com/Prod/link-tracker?*",
372
+ "*://*.lt.emlnk8.com/Prod/link-tracker?*",
373
+ "*://*.lt.emlnk9.com/Prod/link-tracker?*",
374
+ "*://*.bluelena.io/Prod/link-tracker?*",
375
+ "*://*.golfbacksolutions.com/Prod/link-tracker?*",
376
+ "*://*.prospect2.com/Prod/link-tracker?*"
377
+ ],
378
+ "exclude": [],
379
+ "action": "base64,redirect",
380
+ "param": "redirectUrl"
381
+ },
382
+ {
383
+ "include": [
384
+ "*://*.page.link/?*"
385
+ ],
386
+ "exclude": [],
387
+ "action": "redirect",
388
+ "param": "ofl"
389
+ },
390
+ {
391
+ "include": [
392
+ "*://*.cdn.ampproject.org/c/s/*"
393
+ ],
394
+ "pref": "brave.de_amp.enabled",
395
+ "exclude": [],
396
+ "prepend_scheme": "https",
397
+ "action": "regex-path",
398
+ "param": "^/c/s/(.*)$"
399
+ },
400
+ {
401
+ "include": [
402
+ "*://click.redditmail.com/*"
403
+ ],
404
+ "exclude": [],
405
+ "action": "regex-path",
406
+ "param": "^/CL0/([^/]+)/.*$"
407
+ },
408
+ {
409
+ "include": [
410
+ "*://*.streak-link.com/*",
411
+ "*://streaklinks.com/*"
412
+ ],
413
+ "exclude": [],
414
+ "action": "regex-path",
415
+ "param": "^/[^/]+/(.*)$"
416
+ },
417
+ {
418
+ "include": [
419
+ "*://*.turbopages.org/*/s/*"
420
+ ],
421
+ "pref": "brave.de_amp.enabled",
422
+ "exclude": [],
423
+ "prepend_scheme": "https",
424
+ "action": "regex-path",
425
+ "param": "^/([^/]+)/s(/.*)$"
426
+ },
427
+ {
428
+ "include": [
429
+ "*://click.pstmrk.it/2s/*",
430
+ "*://click.pstmrk.it/2sm/*",
431
+ "*://click.pstmrk.it/2ts/*",
432
+ "*://click.pstmrk.it/3s/*",
433
+ "*://click.pstmrk.it/3ts/*"
434
+ ],
435
+ "exclude": [],
436
+ "prepend_scheme": "https",
437
+ "action": "regex-path",
438
+ "param": "^/[23]t?sm?/([^/]+)/.*$"
439
+ },
440
+ {
441
+ "include": [
442
+ "*://click.pstmrk.it/2/*",
443
+ "*://click.pstmrk.it/2m/*",
444
+ "*://click.pstmrk.it/3/*"
445
+ ],
446
+ "exclude": [],
447
+ "prepend_scheme": "http",
448
+ "action": "regex-path",
449
+ "param": "^/[23]m?/([^/]+)/.*$"
450
+ },
451
+ {
452
+ "include": [
453
+ "*://*.awstrack.me/L0/*"
454
+ ],
455
+ "exclude": [],
456
+ "action": "regex-path",
457
+ "param": "^/L0/([^/]+)/.*$"
458
+ },
459
+ {
460
+ "include": [
461
+ "*://shopping.yahoo.com/rdlw?*"
462
+ ],
463
+ "exclude": [],
464
+ "action": "redirect",
465
+ "param": "gcReferrer"
466
+ },
467
+ {
468
+ "include": [
469
+ "*://www.google.com/amp/s/*"
470
+ ],
471
+ "pref": "brave.de_amp.enabled",
472
+ "exclude": [],
473
+ "prepend_scheme": "https",
474
+ "action": "regex-path",
475
+ "param": "^/amp/s/(.*)$"
476
+ },
477
+ {
478
+ "include": [
479
+ "https://buy.geni.us/Proxy.ashx?*"
480
+ ],
481
+ "exclude": [],
482
+ "action": "redirect",
483
+ "param": "GR_URL"
484
+ },
485
+ {
486
+ "include": [
487
+ "https://dev-pages.brave.software/navigation-tracking/error.html?*",
488
+ "https://dev-pages.bravesoftware.com/navigation-tracking/error.html?*"
489
+ ],
490
+ "exclude": [],
491
+ "action": "redirect",
492
+ "param": "brave_testing"
493
+ },
494
+ {
495
+ "include": [
496
+ "https://dev-pages.brave.software/navigation-tracking/error.html?*",
497
+ "https://dev-pages.bravesoftware.com/navigation-tracking/error.html?*"
498
+ ],
499
+ "exclude": [],
500
+ "action": "base64,redirect",
501
+ "param": "brave_testing_base64"
502
+ },
503
+ {
504
+ "include": [
505
+ "https://dev-pages.brave.software/navigation-tracking/regex-multiple-capture-groups/*",
506
+ "https://dev-pages.bravesoftware.com/navigation-tracking/regex-multiple-capture-groups/*"
507
+ ],
508
+ "exclude": [],
509
+ "prepend_scheme": "https",
510
+ "action": "regex-path",
511
+ "param": "^/navigation-tracking/regex-multiple-capture-groups/(.*)/test/(.*);.html$"
512
+ },
513
+ {
514
+ "include": [
515
+ "https://dev-pages.brave.software/navigation-tracking/*",
516
+ "https://dev-pages.bravesoftware.com/navigation-tracking/*"
517
+ ],
518
+ "exclude": [],
519
+ "prepend_scheme": "https",
520
+ "action": "regex-path",
521
+ "param": "^/navigation-tracking/(.*);.html$"
522
+ },
523
+ {
524
+ "include": [
525
+ "*://y2u.be/*"
526
+ ],
527
+ "exclude": [],
528
+ "action": "regex-path-template",
529
+ "param": "^/([^/]+)$",
530
+ "redirect_url_template": "https://www.youtube.com/watch?v=$1"
531
+ }
532
+ ]
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": "5d01c76f8d27",
3
+ "hash": "5d01c76f8d279314e2b337ac429949c7d70a1e3432d28f481fe04fc0a2d36dbb",
4
+ "fetchedAt": "2026-06-03T17:40:39.060Z",
5
+ "upstream": "https://raw.githubusercontent.com/brave/adblock-lists/master/brave-lists/debounce.json",
6
+ "license": "MPL-2.0"
7
+ }
@@ -0,0 +1,6 @@
1
+ import { SanitizerCatalog } from '@url-sanitize/core';
2
+ import { BraveDebounceData, BraveMetadata } from './types.js';
3
+
4
+ declare function braveToCatalog(data: BraveDebounceData, meta: BraveMetadata): SanitizerCatalog;
5
+
6
+ export { braveToCatalog };
@@ -0,0 +1,70 @@
1
+ // src/adapter.ts
2
+ function braveToCatalog(data, meta) {
3
+ const rules = [];
4
+ let index = 0;
5
+ for (const upstreamRule of data) {
6
+ const exceptions = upstreamRule.exclude.map(matchPatternToRegex);
7
+ for (const include of upstreamRule.include) {
8
+ const base = {
9
+ kind: "unwrap-redirect",
10
+ source: "brave",
11
+ provider: `brave-debounce-${index}`,
12
+ urlPattern: matchPatternToRegex(include),
13
+ exceptions,
14
+ pattern: upstreamRule.param,
15
+ captureGroup: 1
16
+ };
17
+ if (upstreamRule.prepend_scheme) base.prependScheme = upstreamRule.prepend_scheme;
18
+ if (upstreamRule.action === "redirect" || upstreamRule.action === "base64,redirect") {
19
+ rules.push({
20
+ ...base,
21
+ pattern: `[?&]${escapeRegExp(upstreamRule.param)}=([^&]+)`,
22
+ captureGroup: 1,
23
+ targetEncoding: upstreamRule.action === "base64,redirect" ? "base64" : "percent"
24
+ });
25
+ } else if (upstreamRule.action === "regex-path") {
26
+ rules.push({
27
+ ...base,
28
+ pattern: upstreamRule.param,
29
+ captureGroup: 1,
30
+ matchPart: "pathname"
31
+ });
32
+ } else {
33
+ const templateRule = {
34
+ ...base,
35
+ pattern: upstreamRule.param,
36
+ captureGroup: 1,
37
+ matchPart: "pathname"
38
+ };
39
+ if (upstreamRule.redirect_url_template) {
40
+ templateRule.targetTemplate = upstreamRule.redirect_url_template;
41
+ }
42
+ rules.push(templateRule);
43
+ }
44
+ index++;
45
+ }
46
+ }
47
+ return {
48
+ version: meta.version,
49
+ generatedAt: meta.fetchedAt,
50
+ sources: [
51
+ {
52
+ name: "brave",
53
+ version: meta.version,
54
+ hash: meta.hash,
55
+ license: meta.license,
56
+ upstream: meta.upstream
57
+ }
58
+ ],
59
+ rules
60
+ };
61
+ }
62
+ function matchPatternToRegex(pattern) {
63
+ return `^${escapeRegExp(pattern).replace(/^\\\*:\/\\\//, "https?:\\/\\/").replace(/\\\*/g, ".*")}$`;
64
+ }
65
+ function escapeRegExp(value) {
66
+ return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
67
+ }
68
+ export {
69
+ braveToCatalog
70
+ };