@adguard/hostlist-compiler 1.0.32 → 1.0.33
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 +10 -2
- package/package.json +1 -1
- package/src/utils.js +1 -11
- package/test/utils.test.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
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
|
+
## [1.0.33] - 2024-12-27
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Bug with checksum calculation. Leave blank lines when counting. [#76]
|
|
13
|
+
|
|
14
|
+
[1.0.33]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.32...v1.0.33
|
|
15
|
+
|
|
8
16
|
## [1.0.32] - 2024-12-27
|
|
9
17
|
|
|
10
18
|
### Fixed
|
|
11
19
|
|
|
12
|
-
- Bug with checksum calculation [#
|
|
20
|
+
- Bug with checksum calculation. Additional line start. [#76]
|
|
13
21
|
|
|
14
22
|
[1.0.32]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.31...v1.0.32
|
|
15
23
|
|
|
@@ -25,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
25
33
|
|
|
26
34
|
[1.0.31]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.29...v1.0.31
|
|
27
35
|
[#63]: https://github.com/AdguardTeam/HostlistCompiler/issues/63
|
|
28
|
-
[#76]: https://github.com/AdguardTeam/
|
|
36
|
+
[#76]: https://github.com/AdguardTeam/HostlistCompiler/issues/76
|
|
29
37
|
|
|
30
38
|
## [1.0.29] - 2024-09-26
|
|
31
39
|
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -18,16 +18,6 @@ const stripEnd = (str, char) => {
|
|
|
18
18
|
return result;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Normalizes data by replacing newlines.
|
|
23
|
-
*
|
|
24
|
-
* @param {string} message - The message to normalize.
|
|
25
|
-
* @returns {string} - The normalized message.
|
|
26
|
-
*/
|
|
27
|
-
const normalizeData = (message) => {
|
|
28
|
-
return message.replace(/\r/g, '').replace(/\n+/g, '\n');
|
|
29
|
-
};
|
|
30
|
-
|
|
31
21
|
/**
|
|
32
22
|
* Calculates checksum for the given header and rules.
|
|
33
23
|
* See:
|
|
@@ -39,7 +29,7 @@ const normalizeData = (message) => {
|
|
|
39
29
|
* @returns {string} - The calculated checksum.
|
|
40
30
|
*/
|
|
41
31
|
const calculateChecksum = (header, rules) => {
|
|
42
|
-
const content =
|
|
32
|
+
const content = header.concat(rules).join('\n');
|
|
43
33
|
const checksum = crypto.createHash('md5').update(content).digest('base64');
|
|
44
34
|
return `! Checksum: ${stripEnd(checksum.trim(), '=')}`;
|
|
45
35
|
};
|
package/test/utils.test.js
CHANGED
|
@@ -62,4 +62,29 @@ describe('calculateChecksum', () => {
|
|
|
62
62
|
const checksum = utils.calculateChecksum(header, rules);
|
|
63
63
|
expect(checksum).toBe(expectedChecksum);
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
it('calculates checksum without stripping empty lines', () => {
|
|
67
|
+
const header = [
|
|
68
|
+
'! Title: 1Hosts (mini)',
|
|
69
|
+
// eslint-disable-next-line max-len
|
|
70
|
+
'! Description: List for blocking pesky ads, trackers, and malware. Lenient version: unblocks a number of ads & trackers for in-app rewards, anti-AdBlock, etc.',
|
|
71
|
+
'! Version: 1.0.14.48',
|
|
72
|
+
'! Homepage: https://badmojr.github.io/1Hosts/',
|
|
73
|
+
'! Last modified: 2024-12-27T09:45:56.615Z',
|
|
74
|
+
'!',
|
|
75
|
+
'! Compiled by @adguard/hostlist-compiler v1.0.32',
|
|
76
|
+
'!',
|
|
77
|
+
];
|
|
78
|
+
const rules = [
|
|
79
|
+
'',
|
|
80
|
+
'||logs.netflix.com^',
|
|
81
|
+
'||teams.events.data.microsoft.com^',
|
|
82
|
+
'||measure.office.net^',
|
|
83
|
+
'||app-analytics-services.com^',
|
|
84
|
+
];
|
|
85
|
+
const expectedChecksum = '! Checksum: 4v+tPGfpA0fy+xfhlr8P6Q';
|
|
86
|
+
|
|
87
|
+
const checksum = utils.calculateChecksum(header, rules);
|
|
88
|
+
expect(checksum).toBe(expectedChecksum);
|
|
89
|
+
});
|
|
65
90
|
});
|