Chore: change domain dedupe method

This commit is contained in:
SukkaW 2023-11-03 11:43:41 +08:00
parent 5701fc9b70
commit 31d021dd23
3 changed files with 5 additions and 8 deletions

View File

@ -20,7 +20,8 @@ const domainDeduper = (inputDomains) => {
// if `.example.com` exists, then `example.com` should also be removed // if `.example.com` exists, then `example.com` should also be removed
const a = d.slice(1); const a = d.slice(1);
if (trie.has(a)) {
if (sets.has(a)) {
sets.delete(a); sets.delete(a);
} }
} }

View File

@ -84,9 +84,7 @@ const createTrie = (from) => {
// eslint-disable-next-line guard-for-in -- plain object // eslint-disable-next-line guard-for-in -- plain object
for (k in node) { for (k in node) {
if (k === SENTINEL) { if (k === SENTINEL) {
if (includeEqualWithSuffix) { if (includeEqualWithSuffix || $suffix !== suffix) {
matches.push($suffix);
} else if ($suffix !== suffix) {
matches.push($suffix); matches.push($suffix);
} }
@ -157,11 +155,9 @@ const createTrie = (from) => {
*/ */
const has = (suffix) => { const has = (suffix) => {
let node = root; let node = root;
let token;
for (let i = suffix.length - 1; i >= 0; i--) { for (let i = suffix.length - 1; i >= 0; i--) {
token = suffix[i]; node = node[suffix[i]];
node = node[token];
if (typeof node === 'undefined') { if (typeof node === 'undefined') {
return false; return false;

View File

@ -1450,7 +1450,7 @@ stat.letv.com
static.app.m.letv.com static.app.m.letv.com
# >> Xiaomi (MIUI) # >> Xiaomi (MIUI)
ad.intl.xiaomi.com .ad.intl.xiaomi.com
.ad.mi.com .ad.mi.com
.admob.xiaomi.com .admob.xiaomi.com
.ad1.xiaomi.com .ad1.xiaomi.com