From 74cd574e731fe494758dd78d2f08db66ee6840b5 Mon Sep 17 00:00:00 2001 From: Hsiaoyi Hsu Date: Sun, 19 Feb 2023 18:19:09 +0800 Subject: fix: getLatencyTestUrl, encode healthcheckProvider name --- src/api/proxies.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/api') diff --git a/src/api/proxies.ts b/src/api/proxies.ts index 97ecd59..36aa05d 100644 --- a/src/api/proxies.ts +++ b/src/api/proxies.ts @@ -37,7 +37,7 @@ export async function requestDelayForProxy( latencyTestUrl = 'http://www.gstatic.com/generate_204' ) { const { url, init } = getURLAndInit(apiConfig); - const qs = `timeout=5000&url=${latencyTestUrl}`; + const qs = `timeout=5000&url=${encodeURIComponent(latencyTestUrl)}`; const fullURL = `${url}${endpoint}/${encodeURIComponent(name)}/delay?${qs}`; return await fetch(fullURL, init); } @@ -48,7 +48,7 @@ export async function requestDelayForProxyGroup( latencyTestUrl = 'http://www.gstatic.com/generate_202' ) { const { url, init } = getURLAndInit(apiConfig); - const qs = `url=${latencyTestUrl}&timeout=2000`; + const qs = `url=${encodeURIComponent(latencyTestUrl)}&timeout=2000`; const fullUrl = `${url}/group/${encodeURIComponent(name)}/delay?${qs}`; return await fetch(fullUrl, init); } @@ -65,11 +65,14 @@ export async function fetchProviderProxies(config) { export async function updateProviderByName(config, name) { const { url, init } = getURLAndInit(config); const options = { ...init, method: 'PUT' }; - return await fetch(url + '/providers/proxies/' + name, options); + return await fetch(url + '/providers/proxies/' + encodeURIComponent(name), options); } export async function healthcheckProviderByName(config, name) { const { url, init } = getURLAndInit(config); const options = { ...init, method: 'GET' }; - return await fetch(url + '/providers/proxies/' + name + '/healthcheck', options); + return await fetch( + url + '/providers/proxies/' + encodeURIComponent(name) + '/healthcheck', + options + ); } -- cgit v1.3.1