Normalized the URL slashes

pull/18209/head
Alexey Volkov 2026-03-19 02:27:48 -07:00
parent ad930e0ba2
commit 2a38d6fbf3
No known key found for this signature in database
GPG Key ID: AD5B02DD0971751E
1 changed files with 3 additions and 2 deletions

View File

@ -98,9 +98,10 @@ if (!(root instanceof HTMLElement) && import.meta.env.DEV) {
}
const getCurrentUrl = () => {
let serverBaseUrl = import.meta.env.VITE_OPENCODE_SERVER_BASE_URL ?? ""
// Normalizing slashes. Add starting slash if needed, remove trailing slash. Default value will be empty string.
serverBaseUrl = ("/" + serverBaseUrl.replace(/^\//, "")).replace(/\/$/, "")
if (location.hostname.includes("opencode.ai")) return "http://localhost:4096"
const serverBaseUrl =
"/" + (import.meta.env.VITE_OPENCODE_SERVER_BASE_URL ?? "/").replace(/^\//, "").replace(/\/$/, "")
if (import.meta.env.DEV)
return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}{serverBaseUrl}`
return location.origin + serverBaseUrl