Skip to content

Commit

Permalink
fix: Encode name to prevent request failure due to '/' in URL (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
Plutonium141 authored Jun 2, 2024
1 parent ce4f67d commit c121167
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ export const fetchProxiesAPI = () => {
export const updateProxyProviderAPI = (providerName: string) => {
const request = useRequest()

return request.put(`providers/proxies/${providerName}`)
return request.put(`providers/proxies/${encodeURIComponent(providerName)}`)
}

export const proxyProviderHealthCheckAPI = (providerName: string) => {
const request = useRequest()

return request
.get(`providers/proxies/${providerName}/healthcheck`, {
.get(`providers/proxies/${encodeURIComponent(providerName)}/healthcheck`, {
timeout: 5 * 1000,
})
.json<Record<string, number>>()
Expand All @@ -151,7 +151,7 @@ export const proxyProviderHealthCheckAPI = (providerName: string) => {
export const selectProxyInGroupAPI = (groupName: string, proxyName: string) => {
const request = useRequest()

return request.put(`proxies/${groupName}`, {
return request.put(`proxies/${encodeURIComponent(groupName)}`, {
body: JSON.stringify({
name: proxyName,
}),
Expand All @@ -173,7 +173,7 @@ export const proxyLatencyTestAPI = (
}

return request
.get(`proxies/${proxyName}/delay`, {
.get(`proxies/${encodeURIComponent(proxyName)}/delay`, {
searchParams: {
url,
timeout,
Expand All @@ -190,7 +190,7 @@ export const proxyGroupLatencyTestAPI = (
const request = useRequest()

return request
.get(`group/${groupName}/delay`, {
.get(`group/${encodeURIComponent(groupName)}/delay`, {
searchParams: {
url,
timeout,
Expand All @@ -216,7 +216,7 @@ export const fetchRuleProvidersAPI = () => {
export const updateRuleProviderAPI = (providerName: string) => {
const request = useRequest()

return request.put(`providers/rules/${providerName}`)
return request.put(`providers/rules/${encodeURIComponent(providerName)}`)
}

type ReleaseAPIResponse = {
Expand Down

0 comments on commit c121167

Please sign in to comment.