@url-sanitize/firefox 2.0.0 → 2.0.2
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/README.md +8 -0
- package/dist/adapter.js +3 -40
- package/dist/chunk-56UUX4DC.js +47 -0
- package/dist/{chunk-ASRH34YB.js → chunk-AEDX63WT.js} +6 -2
- package/dist/index.js +6 -50
- package/dist/raw.js +3 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,6 +16,14 @@ npm install @url-sanitize/core @url-sanitize/firefox
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
+
```ts
|
|
20
|
+
import { sanitize } from '@url-sanitize/firefox';
|
|
21
|
+
|
|
22
|
+
sanitize('https://example.com/?wbraid=x&id=123');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For manual compilation:
|
|
26
|
+
|
|
19
27
|
```ts
|
|
20
28
|
import { compileSanitizer } from '@url-sanitize/core';
|
|
21
29
|
import { firefoxCatalog } from '@url-sanitize/firefox';
|
package/dist/adapter.js
CHANGED
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (const record of data.data) {
|
|
5
|
-
if (record.filter_expression) {
|
|
6
|
-
throw new Error(`Unsupported Firefox filter_expression in record ${record.id}`);
|
|
7
|
-
}
|
|
8
|
-
const exceptions = record.allowList.map(domainPattern);
|
|
9
|
-
for (const param of record.stripList) {
|
|
10
|
-
rules.push({
|
|
11
|
-
kind: "strip-param",
|
|
12
|
-
source: "firefox",
|
|
13
|
-
provider: `firefox-${record.id}`,
|
|
14
|
-
paramPattern: escapeRegExp(param),
|
|
15
|
-
exceptions
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
version: meta.version,
|
|
21
|
-
generatedAt: meta.fetchedAt,
|
|
22
|
-
sources: [
|
|
23
|
-
{
|
|
24
|
-
name: "firefox",
|
|
25
|
-
version: meta.version,
|
|
26
|
-
hash: meta.hash,
|
|
27
|
-
license: meta.license,
|
|
28
|
-
upstream: meta.upstream
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
rules
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function domainPattern(domain) {
|
|
35
|
-
const escaped = escapeRegExp(domain);
|
|
36
|
-
return `^https?:\\/\\/([^/?#]+\\.)?${escaped}(?::[0-9]+)?(?:[/?#]|$)`;
|
|
37
|
-
}
|
|
38
|
-
function escapeRegExp(value) {
|
|
39
|
-
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
40
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
firefoxToCatalog
|
|
3
|
+
} from "./chunk-56UUX4DC.js";
|
|
41
4
|
export {
|
|
42
5
|
firefoxToCatalog
|
|
43
6
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/adapter.ts
|
|
2
|
+
function firefoxToCatalog(data, meta) {
|
|
3
|
+
const rules = [];
|
|
4
|
+
const globalExceptions = data.data.flatMap(
|
|
5
|
+
(record) => record.stripList.length === 0 ? record.allowList.map(domainPattern) : []
|
|
6
|
+
);
|
|
7
|
+
for (const record of data.data) {
|
|
8
|
+
if (record.filter_expression) {
|
|
9
|
+
throw new Error(`Unsupported Firefox filter_expression in record ${record.id}`);
|
|
10
|
+
}
|
|
11
|
+
const exceptions = [...globalExceptions, ...record.allowList.map(domainPattern)];
|
|
12
|
+
for (const param of record.stripList) {
|
|
13
|
+
rules.push({
|
|
14
|
+
kind: "strip-param",
|
|
15
|
+
source: "firefox",
|
|
16
|
+
provider: `firefox-${record.id}`,
|
|
17
|
+
paramPattern: escapeRegExp(param),
|
|
18
|
+
exceptions
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
version: meta.version,
|
|
24
|
+
generatedAt: meta.fetchedAt,
|
|
25
|
+
sources: [
|
|
26
|
+
{
|
|
27
|
+
name: "firefox",
|
|
28
|
+
version: meta.version,
|
|
29
|
+
hash: meta.hash,
|
|
30
|
+
license: meta.license,
|
|
31
|
+
upstream: meta.upstream
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
rules
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function domainPattern(domain) {
|
|
38
|
+
const escaped = escapeRegExp(domain);
|
|
39
|
+
return `^https?:\\/\\/([^/?#]+\\.)?${escaped}(?::[0-9]+)?(?:[/?#]|$)`;
|
|
40
|
+
}
|
|
41
|
+
function escapeRegExp(value) {
|
|
42
|
+
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
firefoxToCatalog
|
|
47
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
firefoxToCatalog
|
|
3
|
+
} from "./chunk-56UUX4DC.js";
|
|
4
|
+
import {
|
|
5
|
+
firefoxMetadata,
|
|
6
|
+
firefoxRawData
|
|
7
|
+
} from "./chunk-AEDX63WT.js";
|
|
5
8
|
|
|
6
9
|
// src/index.ts
|
|
7
10
|
import { compileSanitizer } from "@url-sanitize/core";
|
|
8
|
-
|
|
9
|
-
// src/adapter.js
|
|
10
|
-
function firefoxToCatalog(data, meta) {
|
|
11
|
-
const rules = [];
|
|
12
|
-
for (const record of data.data) {
|
|
13
|
-
if (record.filter_expression) {
|
|
14
|
-
throw new Error(`Unsupported Firefox filter_expression in record ${record.id}`);
|
|
15
|
-
}
|
|
16
|
-
const exceptions = record.allowList.map(domainPattern);
|
|
17
|
-
for (const param of record.stripList) {
|
|
18
|
-
rules.push({
|
|
19
|
-
kind: "strip-param",
|
|
20
|
-
source: "firefox",
|
|
21
|
-
provider: `firefox-${record.id}`,
|
|
22
|
-
paramPattern: escapeRegExp(param),
|
|
23
|
-
exceptions
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
version: meta.version,
|
|
29
|
-
generatedAt: meta.fetchedAt,
|
|
30
|
-
sources: [
|
|
31
|
-
{
|
|
32
|
-
name: "firefox",
|
|
33
|
-
version: meta.version,
|
|
34
|
-
hash: meta.hash,
|
|
35
|
-
license: meta.license,
|
|
36
|
-
upstream: meta.upstream
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
rules
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function domainPattern(domain) {
|
|
43
|
-
const escaped = escapeRegExp(domain);
|
|
44
|
-
return `^https?:\\/\\/([^/?#]+\\.)?${escaped}(?::[0-9]+)?(?:[/?#]|$)`;
|
|
45
|
-
}
|
|
46
|
-
function escapeRegExp(value) {
|
|
47
|
-
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/raw.js
|
|
51
|
-
var firefoxRawData = data_default;
|
|
52
|
-
var firefoxMetadata = metadata_default;
|
|
53
|
-
|
|
54
|
-
// src/index.ts
|
|
55
11
|
var firefoxCatalog = firefoxToCatalog(firefoxRawData, firefoxMetadata);
|
|
56
12
|
var sanitize = compileSanitizer(firefoxCatalog);
|
|
57
13
|
export {
|
package/dist/raw.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
|
|
6
|
-
// src/raw.ts
|
|
7
|
-
var firefoxRawData = data_default;
|
|
8
|
-
var firefoxMetadata = metadata_default;
|
|
2
|
+
firefoxMetadata,
|
|
3
|
+
firefoxRawData
|
|
4
|
+
} from "./chunk-AEDX63WT.js";
|
|
9
5
|
export {
|
|
10
6
|
firefoxMetadata,
|
|
11
7
|
firefoxRawData
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@url-sanitize/firefox",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Firefox Query Stripping 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.2"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"firefox",
|