diff options
| author | Hsiaoyi Hsu <[email protected]> | 2023-02-19 18:19:09 +0800 |
|---|---|---|
| committer | kunish <[email protected]> | 2023-02-19 18:39:27 +0800 |
| commit | 74cd574e731fe494758dd78d2f08db66ee6840b5 (patch) | |
| tree | be958852926cce8292baca8c01d25e7bdedbe738 /src/api | |
| parent | 61e5e67735f77921443f2326323226eb82e00b25 (diff) | |
fix: getLatencyTestUrl, encode healthcheckProvider name
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/proxies.ts | 11 |
1 files changed, 7 insertions, 4 deletions
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 + ); } |
