From 0e7858b15dc620fddfc52522605818f3c161241b Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 1 Sep 2025 20:21:20 -0600 Subject: [PATCH] Redux --- frontend/src/utils/awaitable-websocket.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/awaitable-websocket.js b/frontend/src/utils/awaitable-websocket.js index ad83a81..9ca5f4f 100644 --- a/frontend/src/utils/awaitable-websocket.js +++ b/frontend/src/utils/awaitable-websocket.js @@ -5,7 +5,8 @@ class AwaitableWebSocket extends WebSocket { #opened = false constructor(resolve, reject, url, protocols, binaryType) { - super(url, protocols) + // Support relative URLs even on old browsers that don't + super(new URL(url, location.href.replace(/^http/, 'ws')), protocols) this.binaryType = binaryType || 'blob' this.onopen = () => { this.#opened = true @@ -74,10 +75,10 @@ class AwaitableWebSocket extends WebSocket { } } -// Construct an async WebSocket with await aWebSocket(url) - supports relative URLs even with old browsers that don't +// Construct an async WebSocket with await aWebSocket(url) - relative URLs OK export default function aWebSocket(url, options = {}) { const { protocols, binaryType } = options return new Promise((resolve, reject) => { - new AwaitableWebSocket(resolve, reject, new URL(url, location.href), protocols, binaryType) + new AwaitableWebSocket(resolve, reject, url, protocols, binaryType) }) }