From 15edcc645c231d91d92dad93c6809c3b847ebdf7 Mon Sep 17 00:00:00 2001 From: Marc Plano-Lesay Date: Thu, 7 Jul 2016 15:22:15 +0200 Subject: [PATCH] Fix double slashes in websocket URL --- htdocs/js/mpd.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index 6000b79..1356cef 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -525,6 +525,7 @@ function get_appropriate_ws_url() { var pcol; var u = document.URL; + var separator; /* /* We open the websocket encrypted if this page came on an @@ -542,7 +543,13 @@ function get_appropriate_ws_url() u = u.split('#'); - return pcol + u[0] + "/ws"; + if (/\/$/.test(u[0])) { + separator = ""; + } else { + separator = "/"; + } + + return pcol + u[0] + separator + "ws"; } var updateVolumeIcon = function(volume) -- 2.20.1