summaryrefslogtreecommitdiffhomepage
path: root/src/app/resolve-ws-url.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 01:13:28 +0900
committerAdam Malczewski <[email protected]>2026-06-27 01:13:31 +0900
commit0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99 (patch)
tree0a5a6e62acf2d8e15ec69fd09f641cd75a1bcb10 /src/app/resolve-ws-url.ts
parent397ce9b65b888121d8c7e909c37dfdbffe914673 (diff)
parent576f539670f406280f8398abf78a867d70b683b8 (diff)
downloaddispatch-web-0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99.tar.gz
dispatch-web-0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99.zip
Merge branch 'dev' into feature/heartbeat
# Conflicts: # src/app/App.svelte # src/app/store.svelte.ts # src/app/store.test.ts # src/features/workspaces/ui/WorkspaceCard.test.ts
Diffstat (limited to 'src/app/resolve-ws-url.ts')
-rw-r--r--src/app/resolve-ws-url.ts28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/app/resolve-ws-url.ts b/src/app/resolve-ws-url.ts
index a264606..1c6e259 100644
--- a/src/app/resolve-ws-url.ts
+++ b/src/app/resolve-ws-url.ts
@@ -1,27 +1,27 @@
export interface WsUrlEnv {
- readonly VITE_WS_URL?: string;
- readonly VITE_WS_PORT?: string;
+ readonly VITE_WS_URL?: string;
+ readonly VITE_WS_PORT?: string;
}
export interface WsUrlLocation {
- readonly protocol: string;
- readonly hostname: string;
+ readonly protocol: string;
+ readonly hostname: string;
}
const DEFAULT_PORT = "24205";
const DEFAULT_FALLBACK = "ws://localhost:24205";
export function resolveWsUrl(env: WsUrlEnv, location?: WsUrlLocation): string {
- if (env.VITE_WS_URL !== undefined && env.VITE_WS_URL !== "") {
- return env.VITE_WS_URL;
- }
+ if (env.VITE_WS_URL !== undefined && env.VITE_WS_URL !== "") {
+ return env.VITE_WS_URL;
+ }
- if (location === undefined) {
- return DEFAULT_FALLBACK;
- }
+ if (location === undefined) {
+ return DEFAULT_FALLBACK;
+ }
- const wsProtocol = location.protocol === "https:" ? "wss" : "ws";
- const port =
- env.VITE_WS_PORT !== undefined && env.VITE_WS_PORT !== "" ? env.VITE_WS_PORT : DEFAULT_PORT;
- return `${wsProtocol}://${location.hostname}:${port}`;
+ const wsProtocol = location.protocol === "https:" ? "wss" : "ws";
+ const port =
+ env.VITE_WS_PORT !== undefined && env.VITE_WS_PORT !== "" ? env.VITE_WS_PORT : DEFAULT_PORT;
+ return `${wsProtocol}://${location.hostname}:${port}`;
}