From 074fa1a40f6e3f65bd61109de3f404796e266524 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 8 Aug 2024 14:40:04 +0200 Subject: [PATCH] Let browser construct URL string for us Likely a lot safer for corner cases than us trying to figure this out ourselves. --- app/ui.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/ui.js b/app/ui.js index f27dfe28e..1a9571dc2 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1033,16 +1033,17 @@ const UI = { let url; - url = UI.getSetting('encrypt') ? 'wss' : 'ws'; + url = new URL("https://" + host); - url += '://' + host; + url.protocol = UI.getSetting('encrypt') ? 'wss:' : 'ws:'; if (port) { - url += ':' + port; + url.port = port; } - url += '/' + path; + url.pathname = '/' + path; try { - UI.rfb = new RFB(document.getElementById('noVNC_container'), url, + UI.rfb = new RFB(document.getElementById('noVNC_container'), + url.href, { shared: UI.getSetting('shared'), repeaterID: UI.getSetting('repeaterID'), credentials: { password: password } });