浏览代码

Chore: change domain dedupe method

SukkaW 2 年之前
父节点
当前提交
31d021dd23
共有 3 个文件被更改,包括 5 次插入8 次删除
  1. 2 1
      Build/lib/domain-deduper.js
  2. 2 6
      Build/lib/trie.js
  3. 1 1
      Source/domainset/reject_sukka.conf

+ 2 - 1
Build/lib/domain-deduper.js

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

+ 2 - 6
Build/lib/trie.js

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

+ 1 - 1
Source/domainset/reject_sukka.conf

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