mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Fix/Perf: more efficient and correct whitelisting
This commit is contained in:
@@ -208,6 +208,26 @@ describe('smol tree', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should whitelist trie correctly', () => {
|
||||
const trie = createTrie([
|
||||
'.t.co',
|
||||
't.co',
|
||||
'example.t.co',
|
||||
'.skk.moe'
|
||||
], true, true);
|
||||
|
||||
expect(trie.dump()).toStrictEqual([
|
||||
'.skk.moe',
|
||||
'.t.co'
|
||||
]);
|
||||
|
||||
trie.whitelist('.t.co');
|
||||
expect(trie.dump()).toStrictEqual(['.skk.moe']);
|
||||
|
||||
trie.whitelist('skk.moe');
|
||||
expect(trie.dump()).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should efficiently whitelist domains', () => {
|
||||
const trie = createTrie([
|
||||
'skk.moe',
|
||||
@@ -231,7 +251,6 @@ describe('smol tree', () => {
|
||||
]);
|
||||
|
||||
trie.whitelist('anotherskk.moe');
|
||||
|
||||
expect(trie.dump()).toStrictEqual([
|
||||
'blog.anotherskk.moe'
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user