Only do one livereload replacement

This commit is contained in:
Bjørn Erik Pedersen 2016-02-06 19:22:12 +01:00
parent dd1db334ac
commit 08b582e187

View 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)