mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Chore: new sorting for reject hosts
This commit is contained in:
parent
414150c13e
commit
cac947fd62
@ -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(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user