@adguard/hostlist-compiler 1.0.28 → 1.0.29
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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [1.0.29] - 2024-09-26
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `$network` modifier removing during `RemoveModifiers` transformation [#72]
|
|
14
|
+
|
|
15
|
+
[1.0.29]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.28...v1.0.29
|
|
16
|
+
[#72]: https://github.com/AdguardTeam/FiltersCompiler/issues/72
|
|
17
|
+
|
|
18
|
+
|
|
9
19
|
## [1.0.28] - 2024-09-25
|
|
10
20
|
|
|
11
21
|
### Fix
|
|
@@ -14,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
24
|
|
|
15
25
|
[1.0.28]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.27...v1.0.28
|
|
16
26
|
|
|
27
|
+
|
|
17
28
|
## [1.0.27] - 2024-09-25
|
|
18
29
|
|
|
19
30
|
### Added
|
package/README.md
CHANGED
|
@@ -292,6 +292,7 @@ Here is the list of modifiers that will be removed:
|
|
|
292
292
|
- `$document` and `$doc` modifiers
|
|
293
293
|
- `$all` modifier
|
|
294
294
|
- `$popup` modifier
|
|
295
|
+
- `$network` modifier
|
|
295
296
|
|
|
296
297
|
> [!CAUTION]
|
|
297
298
|
> Blindly removing `$third-party` from traditional ad blocking rules leads to lots of false-positives.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ const ruleUtils = require('../rule');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This transformation simply removes the following modifiers from the adblock-style rules:
|
|
7
|
-
* $document, $doc, $all, $third-party, $3p, $popup
|
|
7
|
+
* $document, $doc, $all, $third-party, $3p, $popup, $network
|
|
8
8
|
*
|
|
9
9
|
* @param {Array<string>} rules - rules to transform
|
|
10
10
|
* @returns {Array<string>} filtered rules
|
|
@@ -35,6 +35,7 @@ function removeModifiers(rules) {
|
|
|
35
35
|
modified = ruleUtils.removeModifier(props, 'document') || modified;
|
|
36
36
|
modified = ruleUtils.removeModifier(props, 'doc') || modified;
|
|
37
37
|
modified = ruleUtils.removeModifier(props, 'popup') || modified;
|
|
38
|
+
modified = ruleUtils.removeModifier(props, 'network') || modified;
|
|
38
39
|
filtered.push(ruleUtils.adblockRuleToString(props));
|
|
39
40
|
|
|
40
41
|
if (modified) {
|
|
@@ -4,13 +4,14 @@ describe('Remove modifiers', () => {
|
|
|
4
4
|
it('simple test', () => {
|
|
5
5
|
const actual = `! test comment
|
|
6
6
|
! next line should have whitespaces. do not remove them. AG-23720
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
||example.org$third-party,important
|
|
9
9
|
||example.net$domain=ya.ru,3p
|
|
10
10
|
||islandofadvert.com^$document,popup
|
|
11
11
|
||example.com$document
|
|
12
12
|
||example.com$doc
|
|
13
13
|
||example.com$all
|
|
14
|
+
||example.com$network
|
|
14
15
|
||example.org^`.split(/\r?\n/);
|
|
15
16
|
|
|
16
17
|
const expected = [
|
|
@@ -24,6 +25,7 @@ describe('Remove modifiers', () => {
|
|
|
24
25
|
'||example.com',
|
|
25
26
|
'||example.com',
|
|
26
27
|
'||example.com',
|
|
28
|
+
'||example.com',
|
|
27
29
|
'||example.org^',
|
|
28
30
|
];
|
|
29
31
|
|
|
@@ -52,7 +52,25 @@ dupl1
|
|
|
52
52
|
exclusions,
|
|
53
53
|
};
|
|
54
54
|
const filtered = await transform(rules, configuration, ['RemoveComments', 'ValidateAllowIp', 'Deduplicate']);
|
|
55
|
-
|
|
55
|
+
expect(filtered).toHaveLength(3);
|
|
56
56
|
expect(filtered).toEqual(['rule1', 'dupl1', '||185.149.120.173^']);
|
|
57
57
|
});
|
|
58
|
+
|
|
59
|
+
it('simple transformations with removeModifiers', async () => {
|
|
60
|
+
const rules = `! test comment
|
|
61
|
+
rule1
|
|
62
|
+
rule2
|
|
63
|
+
||185.149.120.173^$network
|
|
64
|
+
||example.com^$document`.split(/\r?\n/);
|
|
65
|
+
const exclusions = [
|
|
66
|
+
'rule2',
|
|
67
|
+
'', // empty exclusions are ignored
|
|
68
|
+
];
|
|
69
|
+
const configuration = {
|
|
70
|
+
exclusions,
|
|
71
|
+
};
|
|
72
|
+
const filtered = await transform(rules, configuration, ['RemoveModifiers', 'ValidateAllowIp']);
|
|
73
|
+
expect(filtered).toHaveLength(4);
|
|
74
|
+
expect(filtered).toEqual(['! test comment', 'rule1', '||185.149.120.173^', '||example.com^']);
|
|
75
|
+
});
|
|
58
76
|
});
|