@url-sanitize/brave 2.0.4 → 2.0.6
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/dist/adapter.d.ts +5 -6
- package/dist/adapter.js +88 -6
- package/dist/index.d.ts +9 -9
- package/dist/index.js +7 -18
- package/dist/raw-CRKHjTaF.js +470 -0
- package/dist/raw.d.ts +5 -6
- package/dist/raw.js +1 -8
- package/dist/types.d.ts +18 -18
- package/dist/types.js +1 -0
- package/package.json +4 -4
- package/dist/chunk-GEHCLNTD.js +0 -100
- package/dist/chunk-WEZHVFAQ.js +0 -562
package/dist/types.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
export type BraveDebounceAction = 'redirect' | 'base64,redirect' | 'regex-path' | 'regex-path-template' | (string & {});
|
|
3
|
+
export interface BraveDebounceRule {
|
|
4
|
+
action: BraveDebounceAction;
|
|
5
|
+
exclude: string[];
|
|
6
|
+
include: string[];
|
|
7
|
+
param: string;
|
|
8
|
+
prepend_scheme?: 'http' | 'https';
|
|
9
|
+
pref?: string;
|
|
10
|
+
redirect_url_template?: string;
|
|
10
11
|
}
|
|
11
|
-
type BraveDebounceData = BraveDebounceRule[];
|
|
12
|
-
interface BraveMetadata {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export type BraveDebounceData = BraveDebounceRule[];
|
|
13
|
+
export interface BraveMetadata {
|
|
14
|
+
version: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
fetchedAt: string;
|
|
17
|
+
upstream: string;
|
|
18
|
+
license: string;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
export type { BraveDebounceAction, BraveDebounceData, BraveDebounceRule, BraveMetadata };
|
|
20
|
+
//#endregion
|
package/dist/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@url-sanitize/brave",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Brave Debouncer catalog adapter for @url-sanitize/core.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"NOTICE"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@url-sanitize/core": "2.0.
|
|
34
|
+
"@url-sanitize/core": "2.0.6"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"brave",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
52
|
"scripts": {
|
|
53
|
-
"build": "
|
|
54
|
-
"dev": "
|
|
53
|
+
"build": "vp pack",
|
|
54
|
+
"dev": "vp pack --watch"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/dist/chunk-GEHCLNTD.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
const pathRule = {
|
|
27
|
-
...base,
|
|
28
|
-
pattern: upstreamRule.param,
|
|
29
|
-
captureGroup: 1,
|
|
30
|
-
matchPart: "pathname"
|
|
31
|
-
};
|
|
32
|
-
if (upstreamRule.redirect_url_template) {
|
|
33
|
-
pathRule.targetTemplate = upstreamRule.redirect_url_template;
|
|
34
|
-
} else {
|
|
35
|
-
const captureTemplate = captureGroupsTemplate(upstreamRule.param);
|
|
36
|
-
if (captureTemplate) pathRule.targetTemplate = captureTemplate;
|
|
37
|
-
}
|
|
38
|
-
rules.push(pathRule);
|
|
39
|
-
} else if (upstreamRule.action === "regex-path-template") {
|
|
40
|
-
const templateRule = {
|
|
41
|
-
...base,
|
|
42
|
-
pattern: upstreamRule.param,
|
|
43
|
-
captureGroup: 1,
|
|
44
|
-
matchPart: "pathname"
|
|
45
|
-
};
|
|
46
|
-
if (upstreamRule.redirect_url_template) {
|
|
47
|
-
templateRule.targetTemplate = upstreamRule.redirect_url_template;
|
|
48
|
-
}
|
|
49
|
-
rules.push(templateRule);
|
|
50
|
-
} else {
|
|
51
|
-
throw new Error(`Unsupported Brave debounce action: ${upstreamRule.action}`);
|
|
52
|
-
}
|
|
53
|
-
index++;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
version: meta.version,
|
|
58
|
-
generatedAt: meta.fetchedAt,
|
|
59
|
-
sources: [
|
|
60
|
-
{
|
|
61
|
-
name: "brave",
|
|
62
|
-
version: meta.version,
|
|
63
|
-
hash: meta.hash,
|
|
64
|
-
license: meta.license,
|
|
65
|
-
upstream: meta.upstream
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
rules
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function matchPatternToRegex(pattern) {
|
|
72
|
-
pattern = normalizedIncludePattern(pattern);
|
|
73
|
-
if (pattern.startsWith("*://")) {
|
|
74
|
-
return `^https?:\\/\\/${escapeRegExp(pattern.slice("*://".length)).replace(/\\\*/g, ".*")}$`;
|
|
75
|
-
}
|
|
76
|
-
return `^${escapeRegExp(pattern).replace(/\\\*/g, ".*")}$`;
|
|
77
|
-
}
|
|
78
|
-
function normalizedIncludePattern(pattern) {
|
|
79
|
-
if (pattern === "*://www.tkqlhce.com/click-") return `${pattern}*`;
|
|
80
|
-
if (pattern === "*://t.lever-analytics.com/email-link?") return `${pattern}*`;
|
|
81
|
-
return pattern;
|
|
82
|
-
}
|
|
83
|
-
function captureGroupsTemplate(pattern) {
|
|
84
|
-
let count = 0;
|
|
85
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
86
|
-
if (pattern[i] !== "(") continue;
|
|
87
|
-
if (i > 0 && pattern[i - 1] === "\\") continue;
|
|
88
|
-
if (pattern[i + 1] === "?") continue;
|
|
89
|
-
count++;
|
|
90
|
-
}
|
|
91
|
-
if (count <= 1) return void 0;
|
|
92
|
-
return Array.from({ length: count }, (_, index) => `$${index + 1}`).join("");
|
|
93
|
-
}
|
|
94
|
-
function escapeRegExp(value) {
|
|
95
|
-
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export {
|
|
99
|
-
braveToCatalog
|
|
100
|
-
};
|