From f881363d6e6871fc2c4e93e21e2d81643486e076 Mon Sep 17 00:00:00 2001 From: Aaron Ross Date: Wed, 12 Jul 2017 01:57:30 -0400 Subject: [PATCH] Allow for hidden port 80 --- lib/reload-client.js | 6 +++++- lib/reload.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/reload-client.js b/lib/reload-client.js index f094266..348c8c6 100644 --- a/lib/reload-client.js +++ b/lib/reload-client.js @@ -1,6 +1,10 @@ (function refresh () { var verboseLogging = false - var socketUrl = window.location.origin.replace() // This is dynamically populated by the reload.js file before it is sent to the browser + var socketUrl = window.location.origin + if (!window.location.origin.match(/:[0-9]+/)) { + socketUrl = window.location.origin + ':80' + } + socketUrl = socketUrl.replace() // This is dynamically populated by the reload.js file before it is sent to the browser var socket if (verboseLogging) { diff --git a/lib/reload.js b/lib/reload.js index 36fad3f..8f5d784 100644 --- a/lib/reload.js +++ b/lib/reload.js @@ -83,7 +83,7 @@ module.exports = function reload (app, opts, server) { if (verboseLogging) { reloadCode = reloadCode.replace('verboseLogging = false', 'verboseLogging = true') } - reloadCode = reloadCode.replace('window.location.origin.replace()', 'window.location.origin.replace(/(^http(s?):\\/\\/)(.*:)(.*)/,' + (socketPortSpecified ? '\'ws$2://$3' + socketPortSpecified : '\'ws$2://$3$4') + '\')') + reloadCode = reloadCode.replace('socketUrl.replace()', 'socketUrl.replace(/(^http(s?):\\/\\/)(.*:)(.*)/,' + (socketPortSpecified ? '\'ws$2://$3' + socketPortSpecified : '\'ws$2://$3$4') + '\')') expressApp.get(route, function (req, res) { res.type('text/javascript')