Chore: new sorting for reject hosts

This commit is contained in:
SukkaW 2023-03-12 16:27:17 +08:00
parent 414150c13e
commit cac947fd62

View File

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