Files
opencode-manager/frontend/src/lib/websocket-url.ts
T

9 lines
288 B
TypeScript

import { API_BASE_URL } from '@/config'
export function toWebSocketUrl(pathWithQuery: string): string {
const base = API_BASE_URL || window.location.origin
const url = new URL(pathWithQuery, base)
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'
return url.toString()
}