瀏覽代碼

Chore: new sorting for reject hosts

SukkaW 3 年之前
父節點
當前提交
cac947fd62
共有 1 個文件被更改,包括 13 次插入13 次删除
  1. 13 13
      Build/build-reject-domainset.js

+ 13 - 13
Build/build-reject-domainset.js

@@ -250,22 +250,22 @@ const filterRuleWhitelistDomainSets = new Set(PREDEFINED_WHITELIST);
 
 
   console.time('* Write reject.conf');
   console.time('* Write reject.conf');
 
 
-  const getDomainOpt = { allowPrivateDomains: true };
+  const sorter = (a, b) => {
+    if (a.domain > b.domain) {
+      return 1;
+    }
+    if (a.domain < b.domain) {
+      return -1;
+    }
+    return 0;
+  };
   const sortedDomainSets = [...domainSets]
   const sortedDomainSets = [...domainSets]
     .map((v) => {
     .map((v) => {
-      return { v, domain: getDomain(v, getDomainOpt)?.toLowerCase() || v };
-    })
-    .sort((a, b) => {
-      if (a.domain > b.domain) {
-        return 1;
-      }
-      if (a.domain < b.domain) {
-        return -1;
-      }
-      return 0;
+      return { v, domain: getDomain(v.charCodeAt(0) === 46 ? v.slice(1) : v)?.toLowerCase() || v };
     })
     })
-    .map(({ v }) => {
-      return v;
+    .sort(sorter)
+    .map((i) => {
+      return i.v;
     });
     });
 
 
   await compareAndWriteFile(
   await compareAndWriteFile(