Skip to content

Commit

Permalink
Removed the '!' before filter. #76
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 8d28015
Author: jellizaveta <[email protected]>
Date:   Fri Dec 27 11:38:13 2024 +0300

    update date

commit c461b1d
Author: jellizaveta <[email protected]>
Date:   Thu Dec 26 14:17:51 2024 +0300

    update changelog

commit 59f6ea9
Author: jellizaveta <[email protected]>
Date:   Wed Dec 25 14:42:16 2024 +0300

    remove '!' at the beginning of the file from the tests

commit 04d103f
Author: jellizaveta <[email protected]>
Date:   Wed Dec 25 14:37:21 2024 +0300

    Removed the '!' before filter
  • Loading branch information
jellizaveta committed Dec 27, 2024
1 parent 8bc3d2a commit fe6f35d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.32] - 2024-12-27

### Fixed

- Bug with checksum calculation [#63]

[1.0.32]: https://github.com/AdguardTeam/HostlistCompiler/compare/v1.0.31...v1.0.32

## [1.0.31] - 2024-12-23

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function compile(configuration) {
// Calculate checksum
const checksum = calculateChecksum(header, finalList);
// Concat everything together
const data = ['!', checksum, ...header, ...finalList];
const data = [checksum, ...header, ...finalList];
consola.info(`Final length of the list is ${data.length}`);
return data;
}
Expand Down
6 changes: 3 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Hostlist compiler', () => {
const list = await compile(configuration);

// assert
expect(list[1].startsWith('! Checksum:')).toBe(true);
expect(list[0].startsWith('! Checksum:')).toBe(true);
expect(list).toContain('||example.org');
expect(list).toContain('||example.com');
expect(list).toContain('! Version: 1.0.0.9');
Expand Down Expand Up @@ -67,10 +67,10 @@ describe('Hostlist compiler', () => {
const list = await compile(configuration);

// assert
const checksumLine = list[1];
const checksumLine = list[0];
expect(checksumLine.startsWith('! Checksum:')).toBe(true);

const header = list.slice(2, list.indexOf('||example.org'));
const header = list.slice(1, list.indexOf('||example.org'));
const finalList = list.slice(list.indexOf('||example.org'));

const expectedChecksum = calculateChecksum(header, finalList);
Expand Down
6 changes: 3 additions & 3 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ describe('substringBetween', () => {

describe('calculateChecksum', () => {
it('calculates checksum with multiple headers and rules', () => {
const header = ['[Adblock Plus 2.0]', '! Title: Example filter list'];
const rules = ['! Checksum: ', '||example.com^', '||test.com^'];
const expectedChecksum = '! Checksum: h0eMYV8/e57vDmGsYZRhsg';
const header = ['! Title: AdGuard DNS filter', '! Title: Example filter list'];
const rules = ['||example.com^', '||test.com^'];
const expectedChecksum = '! Checksum: VSbHtv4WyU405Fks327CsA';

const checksum = utils.calculateChecksum(header, rules);
expect(checksum).toBe(expectedChecksum);
Expand Down

0 comments on commit fe6f35d

Please sign in to comment.