From 4b8ecc763404e8cd09b3c4cd90f56c028610e10b Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 30 May 2019 22:22:59 +0200 Subject: [PATCH] Dashboard work around Hass.io bug (#575) * Dashboard work around Hass.io bug Ref https://github.com/home-assistant/hassio/issues/1103 * Lint --- esphome/dashboard/static/esphome.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/esphome/dashboard/static/esphome.js b/esphome/dashboard/static/esphome.js index e7c96ec4dd..044c2d70a3 100644 --- a/esphome/dashboard/static/esphome.js +++ b/esphome/dashboard/static/esphome.js @@ -5,12 +5,13 @@ document.addEventListener('DOMContentLoaded', () => { M.AutoInit(document.body); }); -let wsProtocol = "ws:"; -if (window.location.protocol === "https:") { - wsProtocol = 'wss:'; +const loc = window.location; +const wsLoc = new URL("./",`${loc.protocol}//${loc.host}${loc.pathname}`); +wsLoc.protocol = 'ws:'; +if (loc.protocol === "https:") { + wsLoc.protocol = 'wss:'; } -const wsUrl = `${wsProtocol}//${window.location.host}${window.location.pathname}`; - +const wsUrl = wsLoc.href; // ============================= Color Log Parsing ============================= const initializeColorState = () => {