From 045a0ba15893030fd5e96d9aefe810e14ba6dec7 Mon Sep 17 00:00:00 2001 From: Alexander Zeijlon Date: Mon, 10 Mar 2025 11:51:49 +0100 Subject: [PATCH] Let browser handle parsing of URLs before relaying We don't want to assign a path directly to url.pathname that contains a search query, since this causes '?' at the beginning of the query to be URL-encoded to '%3F'. Instead use URL() to parse the path for us. --- app/ui.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index fd23c800..51e57bd3 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1058,7 +1058,12 @@ const UI = { if (port) { url.port = port; } - url.pathname = '/' + path; + + // "./" is needed to force URL() to interpret the path-variable as + // a path and not as an URL. This is relevant if for example path + // starts with more than one "/", in which case it would be + // interpreted as a host name instead. + url = new URL("./" + path, url); } else { // Current (May 2024) browsers support relative WebSocket // URLs natively, but we need to support older browsers for