aboutsummaryrefslogtreecommitdiffhomepage
path: root/livereload
diff options
context:
space:
mode:
authorDan Hersam <[email protected]>2015-01-29 13:30:51 -0500
committerbep <[email protected]>2015-01-30 14:18:17 +0100
commit523f38a9a8f27261d5d95afadfee18489a3b50c1 (patch)
treee1cb797d3a66ab2f6d6e87864d7d0807b94f19ab /livereload
parentd397bc4f43e474529476c8f177e3be4fcd69d593 (diff)
downloadhugo-523f38a9a8f27261d5d95afadfee18489a3b50c1.tar.gz
hugo-523f38a9a8f27261d5d95afadfee18489a3b50c1.zip
Fix for issue 839 and 490 on Windows
The paths were seen as changed but not static because of the backslashes in ev.Name. Once the backslashes were added, I discovered that the JSON sent to livereload was invalid and failed to work because it had backslashes. Hence the code to replace the backslashes from the path to make them work in JSON and for the URL. With this fix, changes to a stylesheet are shown on the page, and if it's a single file that changed, it's reflected in the browser without reloading the whole page.
Diffstat (limited to 'livereload')
-rw-r--r--livereload/livereload.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/livereload/livereload.go b/livereload/livereload.go
index 1b1546158..a47a7b687 100644
--- a/livereload/livereload.go
+++ b/livereload/livereload.go
@@ -15,6 +15,7 @@ package livereload
import (
"net/http"
+ "strings"
"github.com/gorilla/websocket"
)
@@ -44,7 +45,8 @@ func ForceRefresh() {
func RefreshPath(s string) {
// Tell livereload a file has changed - will force a hard refresh if not CSS or an image
- wsHub.broadcast <- []byte(`{"command":"reload","path":"` + s + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`)
+ url_path := strings.Replace(s, "\\", "/", -1) // If path has backslashes on Windows, make path work for URL
+ wsHub.broadcast <- []byte(`{"command":"reload","path":"` + url_path + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`)
}
func ServeJS(w http.ResponseWriter, r *http.Request) {