1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-26 19:14:40 +01:00

fix short write

This commit is contained in:
Oliver Steele 2017-07-24 16:35:50 -04:00
parent 0a0fa46ab3
commit e8a71af452

View File

@ -19,6 +19,7 @@ type TagInjector struct {
// Write injects a livereload script tag at the end of the HTML head, if present,
// else at the beginning of the document.
func (i TagInjector) Write(b []byte) (n int, err error) {
n = len(b)
if !bytes.Contains(b, i.insertion) && bytes.Contains(b, closeHeadTag) {
r := append(i.insertion, closeHeadTag...)
b = bytes.Replace(b, closeHeadTag, r, 1)
@ -26,5 +27,6 @@ func (i TagInjector) Write(b []byte) (n int, err error) {
if !bytes.Contains(b, i.insertion) {
b = append(i.insertion, b...)
}
return i.w.Write(b)
_, err = i.w.Write(b)
return
}