@adguard/hostlist-compiler 1.0.31 → 1.0.32

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
@@ -5,6 +5,14 @@ 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.32] - 2024-12-27
9
+
10
+ ### Fixed
11
+
12
+ - Bug with checksum calculation [#63]
13
+
14
+ [1.0.32]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.31...v1.0.32
15
+
8
16
  ## [1.0.31] - 2024-12-23
9
17
 
10
18
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adguard/hostlist-compiler",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "A simple tool that compiles hosts blocklists from multiple sources",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.js CHANGED
@@ -104,7 +104,7 @@ async function compile(configuration) {
104
104
  // Calculate checksum
105
105
  const checksum = calculateChecksum(header, finalList);
106
106
  // Concat everything together
107
- const data = ['!', checksum, ...header, ...finalList];
107
+ const data = [checksum, ...header, ...finalList];
108
108
  consola.info(`Final length of the list is ${data.length}`);
109
109
  return data;
110
110
  }
@@ -33,7 +33,7 @@ describe('Hostlist compiler', () => {
33
33
  const list = await compile(configuration);
34
34
 
35
35
  // assert
36
- expect(list[1].startsWith('! Checksum:')).toBe(true);
36
+ expect(list[0].startsWith('! Checksum:')).toBe(true);
37
37
  expect(list).toContain('||example.org');
38
38
  expect(list).toContain('||example.com');
39
39
  expect(list).toContain('! Version: 1.0.0.9');
@@ -67,10 +67,10 @@ describe('Hostlist compiler', () => {
67
67
  const list = await compile(configuration);
68
68
 
69
69
  // assert
70
- const checksumLine = list[1];
70
+ const checksumLine = list[0];
71
71
  expect(checksumLine.startsWith('! Checksum:')).toBe(true);
72
72
 
73
- const header = list.slice(2, list.indexOf('||example.org'));
73
+ const header = list.slice(1, list.indexOf('||example.org'));
74
74
  const finalList = list.slice(list.indexOf('||example.org'));
75
75
 
76
76
  const expectedChecksum = calculateChecksum(header, finalList);
@@ -37,9 +37,9 @@ describe('substringBetween', () => {
37
37
 
38
38
  describe('calculateChecksum', () => {
39
39
  it('calculates checksum with multiple headers and rules', () => {
40
- const header = ['[Adblock Plus 2.0]', '! Title: Example filter list'];
41
- const rules = ['! Checksum: ', '||example.com^', '||test.com^'];
42
- const expectedChecksum = '! Checksum: h0eMYV8/e57vDmGsYZRhsg';
40
+ const header = ['! Title: AdGuard DNS filter', '! Title: Example filter list'];
41
+ const rules = ['||example.com^', '||test.com^'];
42
+ const expectedChecksum = '! Checksum: VSbHtv4WyU405Fks327CsA';
43
43
 
44
44
  const checksum = utils.calculateChecksum(header, rules);
45
45
  expect(checksum).toBe(expectedChecksum);