Only do one livereload replacement
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 6 Feb 2016 18:22:12 +0000 (19:22 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 6 Feb 2016 18:22:12 +0000 (19:22 +0100)
transform/livereloadinject.go

index 9eab45f78d31e58d4d9fcde103433a7c2bd8ade6..bd22901dfc1d4b7517ea7fa1cd3196969af7e6f4 100644 (file)
@@ -24,12 +24,12 @@ func LiveReloadInject(ct contentTransformer) {
        replaceTemplate := `<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script>%s`
        replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
 
-       newcontent := bytes.Replace(ct.Content(), match, replace, -1)
+       newcontent := bytes.Replace(ct.Content(), match, replace, 1)
        if len(newcontent) == len(ct.Content()) {
                endBodyTag = "</BODY>"
                replace := []byte(fmt.Sprintf(replaceTemplate, endBodyTag))
                match := []byte(endBodyTag)
-               newcontent = bytes.Replace(ct.Content(), match, replace, -1)
+               newcontent = bytes.Replace(ct.Content(), match, replace, 1)
        }
 
        ct.Write(newcontent)