Skip to content

Commit 074fa1a

Browse files
committed
Let browser construct URL string for us
Likely a lot safer for corner cases than us trying to figure this out ourselves.
1 parent 06f14a5 commit 074fa1a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/ui.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,16 +1033,17 @@ const UI = {
10331033

10341034
let url;
10351035

1036-
url = UI.getSetting('encrypt') ? 'wss' : 'ws';
1036+
url = new URL("https://" + host);
10371037

1038-
url += '://' + host;
1038+
url.protocol = UI.getSetting('encrypt') ? 'wss:' : 'ws:';
10391039
if (port) {
1040-
url += ':' + port;
1040+
url.port = port;
10411041
}
1042-
url += '/' + path;
1042+
url.pathname = '/' + path;
10431043

10441044
try {
1045-
UI.rfb = new RFB(document.getElementById('noVNC_container'), url,
1045+
UI.rfb = new RFB(document.getElementById('noVNC_container'),
1046+
url.href,
10461047
{ shared: UI.getSetting('shared'),
10471048
repeaterID: UI.getSetting('repeaterID'),
10481049
credentials: { password: password } });

0 commit comments

Comments
 (0)