Update CDN & Global & Download Hosts

This commit is contained in:
SukkaW 2024-05-05 00:22:18 +08:00
parent 7d133ea597
commit 53d570e22d
4 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,4 @@
import type { PublicSuffixList } from '@gorhill/publicsuffixlist'; import type { PublicSuffixList } from '@gorhill/publicsuffixlist';
import { createCachedGorhillGetDomain } from './cached-tld-parse';
const compare = (a: string | null, b: string | null) => { const compare = (a: string | null, b: string | null) => {
if (a === b) return 0; if (a === b) return 0;
@ -20,9 +19,9 @@ const compare = (a: string | null, b: string | null) => {
} }
for (let i = 0; i < aLen; i++) { for (let i = 0; i < aLen; i++) {
if (b[i] == null) { // if (b[i] == null) {
return 1; // return 1;
} // }
if (a[i] < b[i]) { if (a[i] < b[i]) {
return -1; return -1;
} }
@ -34,22 +33,20 @@ const compare = (a: string | null, b: string | null) => {
}; };
export const sortDomains = (inputs: string[], gorhill: PublicSuffixList) => { export const sortDomains = (inputs: string[], gorhill: PublicSuffixList) => {
const getDomain = createCachedGorhillGetDomain(gorhill); const domains = inputs.reduce<Map<string, string | null>>((acc, cur) => {
const domains = inputs.reduce<Map<string, string>>((acc, cur) => { if (!acc.has(cur)) {
if (!acc.has(cur)) acc.set(cur, getDomain(cur)); const topD = gorhill.getDomain(cur[0] === '.' ? cur.slice(1) : cur);
acc.set(cur, topD === cur ? null : topD);
};
return acc; return acc;
}, new Map()); }, new Map());
const sorter = (a: string, b: string) => { const sorter = (a: string, b: string) => {
if (a === b) return 0; if (a === b) return 0;
const $a = domains.get(a)!; const $a = domains.get(a) || a;
const $b = domains.get(b)!; const $b = domains.get(b) || b;
// avoid compare same thing twice
if (a === $a && b === $b) {
return compare(a, b);
}
return compare($a, $b) || compare(a, b); return compare($a, $b) || compare(a, b);
}; };

View File

@ -2015,6 +2015,7 @@ i.mt.lv
secure-uploads.ui.com secure-uploads.ui.com
account-cdn.svc.ui.com account-cdn.svc.ui.com
net-fe-static-assets.network-controller.svc.ui.com net-fe-static-assets.network-controller.svc.ui.com
images.svc.ui.com
static.ui.com static.ui.com
# SoftSonic # SoftSonic
.sftcdn.net .sftcdn.net
@ -2649,3 +2650,7 @@ cdn.reimu.net
img.reimu.net img.reimu.net
re.reimu.net re.reimu.net
useruploads.socratic.org useruploads.socratic.org
static.socratic.org
assets.vogue.com
.kuaikan-cdn4.com
.surrit.com

View File

@ -33,6 +33,8 @@ repo.carbon.sh
# KDE # KDE
binary-factory.kde.org binary-factory.kde.org
invent.kde.org invent.kde.org
# Raspberry Pi
downloads.raspberrypi.com
# Linux Mirrors # Linux Mirrors
mirror.navercorp.com mirror.navercorp.com
fedorapeople.org fedorapeople.org

View File

@ -327,6 +327,7 @@ DOMAIN-SUFFIX,bwh1.net
DOMAIN-SUFFIX,castbox.fm DOMAIN-SUFFIX,castbox.fm
DOMAIN-SUFFIX,cbc.ca DOMAIN-SUFFIX,cbc.ca
DOMAIN,ccmdl.adobe.com DOMAIN,ccmdl.adobe.com
DOMAIN-SUFFIX,cdpn.io
DOMAIN-SUFFIX,change.org DOMAIN-SUFFIX,change.org
DOMAIN-SUFFIX,character.ai DOMAIN-SUFFIX,character.ai
DOMAIN-SUFFIX,cloudfront.net DOMAIN-SUFFIX,cloudfront.net