Should encode names in provider API url

This commit is contained in:
Haishan 2022-07-23 20:15:26 +08:00
parent 2552ccbe0b
commit 4a8d7d70cb

View file

@ -61,11 +61,11 @@ export async function fetchProviderProxies(config: ClashAPIConfig) {
export async function updateProviderByName(config: ClashAPIConfig, name: string) {
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: ClashAPIConfig, name: string) {
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);
}