From 13f3bed5fe521087d267974872ef57baaf3e138c Mon Sep 17 00:00:00 2001 From: LordMathis Date: Tue, 21 Oct 2025 23:36:26 +0200 Subject: [PATCH] Add URL encoding for instance name in API calls in webui --- webui/src/lib/api.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/webui/src/lib/api.ts b/webui/src/lib/api.ts index 8629c1f..ef03408 100644 --- a/webui/src/lib/api.ts +++ b/webui/src/lib/api.ts @@ -116,7 +116,7 @@ export const nodesApi = { list: () => apiCall("/nodes"), // GET /nodes/{name} - get: (name: string) => apiCall(`/nodes/${name}`), + get: (name: string) => apiCall(`/nodes/${encodeURIComponent(name)}`), }; // Instance API functions @@ -125,52 +125,52 @@ export const instancesApi = { list: () => apiCall("/instances"), // GET /instances/{name} - get: (name: string) => apiCall(`/instances/${name}`), + get: (name: string) => apiCall(`/instances/${encodeURIComponent(name)}`), // POST /instances/{name} create: (name: string, options: CreateInstanceOptions) => - apiCall(`/instances/${name}`, { + apiCall(`/instances/${encodeURIComponent(name)}`, { method: "POST", body: JSON.stringify(options), }), // PUT /instances/{name} update: (name: string, options: CreateInstanceOptions) => - apiCall(`/instances/${name}`, { + apiCall(`/instances/${encodeURIComponent(name)}`, { method: "PUT", body: JSON.stringify(options), }), // DELETE /instances/{name} delete: (name: string) => - apiCall(`/instances/${name}`, { + apiCall(`/instances/${encodeURIComponent(name)}`, { method: "DELETE", }), // POST /instances/{name}/start start: (name: string) => - apiCall(`/instances/${name}/start`, { + apiCall(`/instances/${encodeURIComponent(name)}/start`, { method: "POST", }), // POST /instances/{name}/stop stop: (name: string) => - apiCall(`/instances/${name}/stop`, { + apiCall(`/instances/${encodeURIComponent(name)}/stop`, { method: "POST", }), // POST /instances/{name}/restart restart: (name: string) => - apiCall(`/instances/${name}/restart`, { + apiCall(`/instances/${encodeURIComponent(name)}/restart`, { method: "POST", }), // GET /instances/{name}/logs getLogs: (name: string, lines?: number) => { const params = lines ? `?lines=${lines}` : ""; - return apiCall(`/instances/${name}/logs${params}`, {}, "text"); + return apiCall(`/instances/${encodeURIComponent(name)}/logs${params}`, {}, "text"); }, // GET /instances/{name}/proxy/health - getHealth: (name: string) => apiCall>(`/instances/${name}/proxy/health`), + getHealth: (name: string) => apiCall>(`/instances/${encodeURIComponent(name)}/proxy/health`), };