livereload: Fix recently broken window.location.reload logic
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 18 Nov 2017 09:54:07 +0000 (10:54 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 18 Nov 2017 09:54:07 +0000 (10:54 +0100)
Closes #4100

livereload/livereload.go

index 90096577d2f44f003a9f27dda50fdfe2a3556a49..7bfbbaf6b870738b6d419b4e7b45a88a71c1c0c8 100644 (file)
@@ -163,11 +163,13 @@ HugoReload.prototype.reload = function(path, options) {
        }
        
        path = path.substring(prefix.length);
+
+       var portChanged = options.overrideURL && options.overrideURL != window.location.port
        
-       if (!options.overrideURL && window.location.pathname === path) {
+       if (!portChanged && window.location.pathname === path) {
                window.location.reload();
        } else {
-               if (options.overrideURL) {
+               if (portChanged) {
                        window.location = location.protocol + "//" + location.hostname + ":" + options.overrideURL + path;
                } else {
                        window.location.pathname = path;