livereload: Simplify RefreshPath

This commit is contained in:
Cameron Moore authored and Bjørn Erik Pedersen committed 2016-12-28 11:09:50 +01:00
1 parent 88b5bbd532
commit 6affd31b3e
1 file changed
+3 -3
+3 -3
View File
@@ -38,7 +38,7 @@ package livereload
import ( import (
"net/http" "net/http"
"strings" "path/filepath"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
) )
@@ -74,8 +74,8 @@ func ForceRefresh() {
// will be updated in the browser, not the entire page. // will be updated in the browser, not the entire page.
func RefreshPath(s string) { func RefreshPath(s string) {
// Tell livereload a file has changed - will force a hard refresh if not CSS or an image // Tell livereload a file has changed - will force a hard refresh if not CSS or an image
urlPath := strings.Replace(s, "\\", "/", -1) // If path has backslashes on Windows, make path work for URL urlPath := filepath.ToSlash(s)
wsHub.broadcast <- []byte(`{"command":"reload","path":"` + urlPath + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`) wsHub.broadcast <- []byte(`{"command":"reload","path":"` + urlPath + `","originalPath":"","liveCSS":true,"liveImg":true}`)
} }
// ServeJS serves the liverreload.js who's reference is injected into the page. // ServeJS serves the liverreload.js who's reference is injected into the page.