|
@@ -144,8 +144,6 @@ describe('smol tree', () => {
|
|
|
'.blog.sub.example.com', 'sub.example.com', 'cdn.sub.example.com', '.sub.example.com'
|
|
'.blog.sub.example.com', 'sub.example.com', 'cdn.sub.example.com', '.sub.example.com'
|
|
|
], true, true);
|
|
], true, true);
|
|
|
|
|
|
|
|
- console.log(trie);
|
|
|
|
|
-
|
|
|
|
|
expect(trie.dump()).toStrictEqual([
|
|
expect(trie.dump()).toStrictEqual([
|
|
|
'.sub.example.com',
|
|
'.sub.example.com',
|
|
|
'cdn.noc.one', 'www.noc.one',
|
|
'cdn.noc.one', 'www.noc.one',
|
|
@@ -153,13 +151,11 @@ describe('smol tree', () => {
|
|
|
]);
|
|
]);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it.only('should create simple tree - 2', () => {
|
|
|
|
|
|
|
+ it('should create simple tree - 2', () => {
|
|
|
const trie = createTrie([
|
|
const trie = createTrie([
|
|
|
'.skk.moe', 'blog.skk.moe', '.cdn.skk.moe', 'skk.moe'
|
|
'.skk.moe', 'blog.skk.moe', '.cdn.skk.moe', 'skk.moe'
|
|
|
], true, true);
|
|
], true, true);
|
|
|
|
|
|
|
|
- console.log({ trie });
|
|
|
|
|
-
|
|
|
|
|
expect(trie.dump()).toStrictEqual([
|
|
expect(trie.dump()).toStrictEqual([
|
|
|
'.skk.moe'
|
|
'.skk.moe'
|
|
|
]);
|
|
]);
|
|
@@ -170,8 +166,6 @@ describe('smol tree', () => {
|
|
|
'.blog.sub.example.com', 'cdn.sub.example.com', '.sub.example.com'
|
|
'.blog.sub.example.com', 'cdn.sub.example.com', '.sub.example.com'
|
|
|
], true, true);
|
|
], true, true);
|
|
|
|
|
|
|
|
- console.log(trie);
|
|
|
|
|
-
|
|
|
|
|
expect(trie.dump()).toStrictEqual([
|
|
expect(trie.dump()).toStrictEqual([
|
|
|
'.sub.example.com'
|
|
'.sub.example.com'
|
|
|
]);
|
|
]);
|
|
@@ -197,4 +191,54 @@ describe('smol tree', () => {
|
|
|
'act.commercial.shouji.360.cn'
|
|
'act.commercial.shouji.360.cn'
|
|
|
]);
|
|
]);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ it('should dedupe subdomain properly', () => {
|
|
|
|
|
+ const trie = createTrie([
|
|
|
|
|
+ 'skk.moe',
|
|
|
|
|
+ 'anotherskk.moe',
|
|
|
|
|
+ 'blog.anotherskk.moe',
|
|
|
|
|
+ 'blog.skk.moe'
|
|
|
|
|
+ ], true, true);
|
|
|
|
|
+
|
|
|
|
|
+ expect(trie.dump()).toStrictEqual([
|
|
|
|
|
+ 'anotherskk.moe',
|
|
|
|
|
+ 'blog.anotherskk.moe',
|
|
|
|
|
+ 'skk.moe',
|
|
|
|
|
+ 'blog.skk.moe'
|
|
|
|
|
+ ]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should efficiently whitelist domains', () => {
|
|
|
|
|
+ const trie = createTrie([
|
|
|
|
|
+ 'skk.moe',
|
|
|
|
|
+ 'anotherskk.moe',
|
|
|
|
|
+ 'blog.anotherskk.moe',
|
|
|
|
|
+ 'blog.skk.moe'
|
|
|
|
|
+ ], true, true);
|
|
|
|
|
+
|
|
|
|
|
+ expect(trie.dump()).toStrictEqual([
|
|
|
|
|
+ 'anotherskk.moe',
|
|
|
|
|
+ 'blog.anotherskk.moe',
|
|
|
|
|
+ 'skk.moe',
|
|
|
|
|
+ 'blog.skk.moe'
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ trie.whitelist('.skk.moe');
|
|
|
|
|
+
|
|
|
|
|
+ expect(trie.dump()).toStrictEqual([
|
|
|
|
|
+ 'anotherskk.moe',
|
|
|
|
|
+ 'blog.anotherskk.moe'
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ trie.whitelist('anotherskk.moe');
|
|
|
|
|
+
|
|
|
|
|
+ expect(trie.dump()).toStrictEqual([
|
|
|
|
|
+ 'blog.anotherskk.moe'
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ trie.add('anotherskk.moe');
|
|
|
|
|
+ trie.whitelist('.anotherskk.moe');
|
|
|
|
|
+
|
|
|
|
|
+ expect(trie.dump()).toStrictEqual([]);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|