diff --git a/Build/lib/fetch-text-by-line.bench.ts b/Build/lib/fetch-text-by-line.bench.ts index e102354f..a93ff214 100644 --- a/Build/lib/fetch-text-by-line.bench.ts +++ b/Build/lib/fetch-text-by-line.bench.ts @@ -7,7 +7,7 @@ import { SOURCE_DIR } from '../constants/dir'; const file = path.join(SOURCE_DIR, 'domainset/cdn.conf'); -group('read file by line', () => { +group(() => { bench('readFileByLine', () => processLineFromReadline(readFileByLine(file))); bench('fsp.readFile', () => fsp.readFile(file, 'utf-8').then((content) => content.split('\n').filter(processLine))); }); diff --git a/Build/lib/parse-filter.test.ts b/Build/lib/parse-filter.test.ts index 59a7f9cf..7314cbb6 100644 --- a/Build/lib/parse-filter.test.ts +++ b/Build/lib/parse-filter.test.ts @@ -11,7 +11,7 @@ describe('parse', () => { const MUTABLE_PARSE_LINE_RESULT: [string, ParseType] = ['', 1000]; it('||top.mail.ru^$badfilter', () => { - console.log(parse('||top.mail.ru^$badfilter', MUTABLE_PARSE_LINE_RESULT)); + console.log(parse('||top.mail.ru^$badfilter', MUTABLE_PARSE_LINE_RESULT, false)); }); }); diff --git a/Build/lib/rules/ip.ts b/Build/lib/rules/ip.ts index b375ef0d..fc8ba9da 100644 --- a/Build/lib/rules/ip.ts +++ b/Build/lib/rules/ip.ts @@ -15,6 +15,8 @@ export class IPListOutput extends RuleOutput { super(span, id); } + mitmSgmodule = undefined; + protected preprocess() { const results: string[] = []; appendArrayInPlace( diff --git a/Build/lib/set-add-from-array.bench.ts b/Build/lib/set-add-from-array.bench.ts index 2077bd6c..85730de4 100644 --- a/Build/lib/set-add-from-array.bench.ts +++ b/Build/lib/set-add-from-array.bench.ts @@ -6,16 +6,16 @@ import { bench, group, run } from 'mitata'; (async () => { const data = await processLineFromReadline(await fetchRemoteTextByLine('https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt')); - group('setAddFromArray', () => { - bench('run', () => { + group(() => { + bench('setAddFromArray', () => { const set = new Set(['1', '2', '1', '3', 'skk.moe']); for (let i = 0, len = data.length; i < len; i++) { set.add(data[i]); } }); }); - group('setAddFromArray', () => { - bench('run', () => { + group(() => { + bench('', () => { const set = new Set(['1', '2', '1', '3', 'skk.moe']); // eslint-disable-next-line @typescript-eslint/unbound-method -- thisArg is passed data.forEach(set.add, set); diff --git a/Build/lib/stable-sort-domain.bench.ts b/Build/lib/stable-sort-domain.bench.ts index 84636f68..78094b6d 100644 --- a/Build/lib/stable-sort-domain.bench.ts +++ b/Build/lib/stable-sort-domain.bench.ts @@ -7,8 +7,8 @@ import { bench, group, run } from 'mitata'; (async () => { const data = await processLineFromReadline(await fetchRemoteTextByLine('https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt')); - group('sortDomains', () => { - bench('run', () => sortDomains(data)); + group(() => { + bench('sortDomains', () => sortDomains(data)); }); run(); diff --git a/Build/lib/tldts.bench.ts b/Build/lib/tldts.bench.ts index e2d020f5..6c7b81be 100644 --- a/Build/lib/tldts.bench.ts +++ b/Build/lib/tldts.bench.ts @@ -18,7 +18,7 @@ import * as tldtsExperimental from 'tldts-experimental'; }; (['getDomain', 'getPublicSuffix', 'getSubdomain', 'parse'] as const).forEach(methodName => { - group(methodName, () => { + group(() => { bench('tldts', () => { for (let i = 0, len = data.length; i < len; i++) { tldts[methodName](data[i], tldtsOpt); diff --git a/Build/lib/trie.test.ts b/Build/lib/trie.test.ts index 6fea8bf4..bf0a4663 100644 --- a/Build/lib/trie.test.ts +++ b/Build/lib/trie.test.ts @@ -35,7 +35,7 @@ describe('hostname to tokens', () => { describe('Trie', () => { it('should be possible to add domains to a Trie.', () => { - const trie = createTrie(); + const trie = createTrie(null, false); trie.add('a.skk.moe'); trie.add('skk.moe'); @@ -52,7 +52,7 @@ describe('Trie', () => { }); it('adding the same item several times should not increase size.', () => { - const trie = createTrie(); + const trie = createTrie(null, false); trie.add('skk.moe'); trie.add('blog.skk.moe'); @@ -63,7 +63,7 @@ describe('Trie', () => { }); it('should be possible to set the null sequence.', () => { - let trie = createTrie(); + let trie = createTrie(null, false); trie.add(''); expect(trie.has('')).to.equal(true); @@ -123,6 +123,23 @@ describe('Trie', () => { expect(trie.find('')).to.deep.equal(['example.org', 'example.com', 'cdn.example.com', 'blog.example.com']); }); + it('should be possible to retrieve items matching the given prefix even with a smol trie.', () => { + const trie = createTrie(null, true); + + trie.add('.example.com'); + trie.add('example.com'); + trie.add('blog.example.com'); + trie.add('cdn.example.com'); + trie.add('example.org'); + + expect(trie.find('example.com')).to.deep.equal(['.example.com']); + expect(trie.find('com')).to.deep.equal(['.example.com']); + expect(trie.find('.example.com')).to.deep.equal(['.example.com']); + expect(trie.find('org')).to.deep.equal(['example.org']); + expect(trie.find('example.net')).to.deep.equal([]); + expect(trie.find('')).to.deep.equal(['example.org', '.example.com']); + }); + it('should be possible to create a trie from an arbitrary iterable.', () => { let trie = createTrie(['skk.moe', 'blog.skk.moe']);