mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Perf: use fast-uri in speedtest hosts
This commit is contained in:
parent
58aed6aa60
commit
3d56bb540a
@ -9,6 +9,8 @@ import { DomainsetOutput } from './lib/rules/domainset';
|
|||||||
import { OUTPUT_SURGE_DIR, SOURCE_DIR } from './constants/dir';
|
import { OUTPUT_SURGE_DIR, SOURCE_DIR } from './constants/dir';
|
||||||
import { $$fetch } from './lib/fetch-retry';
|
import { $$fetch } from './lib/fetch-retry';
|
||||||
|
|
||||||
|
import { fastUri } from 'fast-uri';
|
||||||
|
|
||||||
interface SpeedTestServer {
|
interface SpeedTestServer {
|
||||||
url: string,
|
url: string,
|
||||||
lat: string,
|
lat: string,
|
||||||
@ -27,7 +29,7 @@ interface SpeedTestServer {
|
|||||||
const getSpeedtestHostsGroupsPromise = $$fetch('https://speedtest-net-servers.cdn.skk.moe/servers.json')
|
const getSpeedtestHostsGroupsPromise = $$fetch('https://speedtest-net-servers.cdn.skk.moe/servers.json')
|
||||||
.then(res => res.json() as Promise<SpeedTestServer[]>)
|
.then(res => res.json() as Promise<SpeedTestServer[]>)
|
||||||
.then((data) => data.reduce<string[]>((prev, cur) => {
|
.then((data) => data.reduce<string[]>((prev, cur) => {
|
||||||
let hn: string | null = null;
|
let hn: string | null | undefined = null;
|
||||||
if (cur.host) {
|
if (cur.host) {
|
||||||
hn = tldts.getHostname(cur.host, { detectIp: false, validateHostname: true });
|
hn = tldts.getHostname(cur.host, { detectIp: false, validateHostname: true });
|
||||||
if (hn) {
|
if (hn) {
|
||||||
@ -35,7 +37,7 @@ const getSpeedtestHostsGroupsPromise = $$fetch('https://speedtest-net-servers.cd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cur.url) {
|
if (cur.url) {
|
||||||
hn = tldts.getHostname(cur.url, { detectIp: false, validateHostname: true });
|
hn = fastUri.parse(cur.url).host;
|
||||||
if (hn) {
|
if (hn) {
|
||||||
prev.push(hn);
|
prev.push(hn);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
"dns2": "^2.1.0",
|
"dns2": "^2.1.0",
|
||||||
"fast-cidr-tools": "^0.3.2",
|
"fast-cidr-tools": "^0.3.2",
|
||||||
"fast-fifo": "^1.3.2",
|
"fast-fifo": "^1.3.2",
|
||||||
|
"fast-uri": "^3.0.6",
|
||||||
"fdir": "^6.4.6",
|
"fdir": "^6.4.6",
|
||||||
"foxts": "^3.6.0",
|
"foxts": "^3.6.0",
|
||||||
"hash-wasm": "^4.12.0",
|
"hash-wasm": "^4.12.0",
|
||||||
|
|||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -49,6 +49,9 @@ importers:
|
|||||||
fast-fifo:
|
fast-fifo:
|
||||||
specifier: ^1.3.2
|
specifier: ^1.3.2
|
||||||
version: 1.3.2
|
version: 1.3.2
|
||||||
|
fast-uri:
|
||||||
|
specifier: ^3.0.6
|
||||||
|
version: 3.0.6
|
||||||
fdir:
|
fdir:
|
||||||
specifier: ^6.4.6
|
specifier: ^6.4.6
|
||||||
version: 6.4.6(picomatch@4.0.2)
|
version: 6.4.6(picomatch@4.0.2)
|
||||||
@ -1309,6 +1312,9 @@ packages:
|
|||||||
fast-levenshtein@2.0.6:
|
fast-levenshtein@2.0.6:
|
||||||
resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==}
|
resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==}
|
||||||
|
|
||||||
|
fast-uri@3.0.6:
|
||||||
|
resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==}
|
||||||
|
|
||||||
fastq@1.19.1:
|
fastq@1.19.1:
|
||||||
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
|
||||||
|
|
||||||
@ -3199,6 +3205,8 @@ snapshots:
|
|||||||
|
|
||||||
fast-levenshtein@2.0.6: {}
|
fast-levenshtein@2.0.6: {}
|
||||||
|
|
||||||
|
fast-uri@3.0.6: {}
|
||||||
|
|
||||||
fastq@1.19.1:
|
fastq@1.19.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
reusify: 1.1.0
|
reusify: 1.1.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user