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,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 }; return { v, domain: getDomain(v.charCodeAt(0) === 46 ? v.slice(1) : v)?.toLowerCase() || v };
}) })
.sort((a, b) => { .sort(sorter)
if (a.domain > b.domain) { .map((i) => {
return 1; return i.v;
}
if (a.domain < b.domain) {
return -1;
}
return 0;
})
.map(({ v }) => {
return v;
}); });
await compareAndWriteFile( await compareAndWriteFile(