diff options
author | Bjørn Erik Pedersen <[email protected]> | 2020-01-31 08:02:53 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-01-31 08:02:53 +0100 |
commit | ef78a0d18a13098bcea1ff2b2d45d7388b8d41a0 (patch) | |
tree | 8c005dacddf72aa60ab8af9f289fec90fa7cabc0 /transform | |
parent | 585958645372e6219239247dbac02e447d2b355b (diff) | |
download | hugo-ef78a0d18a13098bcea1ff2b2d45d7388b8d41a0.tar.gz hugo-ef78a0d18a13098bcea1ff2b2d45d7388b8d41a0.zip |
transform/livereloadinject: Don't use document.write to inject livereload
I suspect the person who originally implemented it saw examples using location.host etc. to build the URL.
We have all that information ready at build (static) time.
Fixes #6507
Diffstat (limited to 'transform')
-rw-r--r-- | transform/livereloadinject/livereloadinject.go | 2 | ||||
-rw-r--r-- | transform/livereloadinject/livereloadinject_test.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/transform/livereloadinject/livereloadinject.go b/transform/livereloadinject/livereloadinject.go index f34b4fb59..896dcab4e 100644 --- a/transform/livereloadinject/livereloadinject.go +++ b/transform/livereloadinject/livereloadinject.go @@ -59,7 +59,7 @@ func New(port int) transform.Transformer { return err } - script := []byte(fmt.Sprintf(`<script data-no-instant>document.write('<script src="/livereload.js?port=%d&mindelay=10&v=2"></' + 'script>')</script>`, port)) + script := []byte(fmt.Sprintf(`<script src="/livereload.js?port=%d&mindelay=10&v=2" data-no-instant></script>`, port)) i := idx if match.appendScript { diff --git a/transform/livereloadinject/livereloadinject_test.go b/transform/livereloadinject/livereloadinject_test.go index 4dd256bb0..ea1b3aa65 100644 --- a/transform/livereloadinject/livereloadinject_test.go +++ b/transform/livereloadinject/livereloadinject_test.go @@ -25,7 +25,7 @@ import ( func TestLiveReloadInject(t *testing.T) { c := qt.New(t) - expectBase := `<script data-no-instant>document.write('<script src="/livereload.js?port=1313&mindelay=10&v=2"></' + 'script>')</script>` + expectBase := `<script src="/livereload.js?port=1313&mindelay=10&v=2" data-no-instant></script>` apply := func(s string) string { out := new(bytes.Buffer) in := strings.NewReader(s) |