mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-10 19:54:08 +02:00
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
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user