fix: Encode name to prevent request failure due to '/' in URL (#734)

This commit is contained in:
Plutonium141 2024-06-02 21:23:13 +08:00 committed by GitHub
parent ce4f67d650
commit c121167407
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -135,14 +135,14 @@ export const fetchProxiesAPI = () => {
export const updateProxyProviderAPI = (providerName: string) => { export const updateProxyProviderAPI = (providerName: string) => {
const request = useRequest() const request = useRequest()
return request.put(`providers/proxies/${providerName}`) return request.put(`providers/proxies/${encodeURIComponent(providerName)}`)
} }
export const proxyProviderHealthCheckAPI = (providerName: string) => { export const proxyProviderHealthCheckAPI = (providerName: string) => {
const request = useRequest() const request = useRequest()
return request return request
.get(`providers/proxies/${providerName}/healthcheck`, { .get(`providers/proxies/${encodeURIComponent(providerName)}/healthcheck`, {
timeout: 5 * 1000, timeout: 5 * 1000,
}) })
.json<Record<string, number>>() .json<Record<string, number>>()
@ -151,7 +151,7 @@ export const proxyProviderHealthCheckAPI = (providerName: string) => {
export const selectProxyInGroupAPI = (groupName: string, proxyName: string) => { export const selectProxyInGroupAPI = (groupName: string, proxyName: string) => {
const request = useRequest() const request = useRequest()
return request.put(`proxies/${groupName}`, { return request.put(`proxies/${encodeURIComponent(groupName)}`, {
body: JSON.stringify({ body: JSON.stringify({
name: proxyName, name: proxyName,
}), }),
@ -173,7 +173,7 @@ export const proxyLatencyTestAPI = (
} }
return request return request
.get(`proxies/${proxyName}/delay`, { .get(`proxies/${encodeURIComponent(proxyName)}/delay`, {
searchParams: { searchParams: {
url, url,
timeout, timeout,
@ -190,7 +190,7 @@ export const proxyGroupLatencyTestAPI = (
const request = useRequest() const request = useRequest()
return request return request
.get(`group/${groupName}/delay`, { .get(`group/${encodeURIComponent(groupName)}/delay`, {
searchParams: { searchParams: {
url, url,
timeout, timeout,
@ -216,7 +216,7 @@ export const fetchRuleProvidersAPI = () => {
export const updateRuleProviderAPI = (providerName: string) => { export const updateRuleProviderAPI = (providerName: string) => {
const request = useRequest() const request = useRequest()
return request.put(`providers/rules/${providerName}`) return request.put(`providers/rules/${encodeURIComponent(providerName)}`)
} }
type ReleaseAPIResponse = { type ReleaseAPIResponse = {