From 4855aa5f5ac00677fc5b708051c16049c3779d80 Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Tue, 1 Oct 2019 15:36:39 +0200 Subject: [PATCH] server querystring --- README.md | 2 +- app/js/lib/mpd.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ba44b1..c62760b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ npm i node . ``` -Point your browser to http://localhost:8080 to open the interface. +Point your browser to http://localhost:8080 to open the interface. Specify a custom MPD address via a `server` querystring argument (`?server=localhost:6655`). ## Technology diff --git a/app/js/lib/mpd.js b/app/js/lib/mpd.js index 2feeadb..49afefe 100644 --- a/app/js/lib/mpd.js +++ b/app/js/lib/mpd.js @@ -143,7 +143,11 @@ export async function init() { return new Promise((resolve, reject) => { try { - ws = new WebSocket(`ws://${location.host}/?ticket=${encodeURIComponent(ticket)}`); + let url = new URL(location.href); + url.protocol = "ws"; + url.hash = ""; + url.searchParams.set("ticket", ticket); + ws = new WebSocket(url.href); } catch (e) { reject(e); } current = {resolve, reject};