diff --git a/transform/livereloadinject.go b/transform/livereloadinject.go index 38e4e8cc9..2fb130c17 100644 --- a/transform/livereloadinject.go +++ b/transform/livereloadinject.go @@ -2,18 +2,13 @@ package transform import ( "bytes" - "github.com/spf13/viper" ) func LiveReloadInject(ct contentTransformer) { match := []byte("") - port := viper.GetString("port") - replace := []byte(``) - newcontent := bytes.Replace(ct.Content(), match, replace, -1) + replace := []byte(``) + newcontent := bytes.Replace(ct.Content(), match, replace, -1) if len(newcontent) == len(ct.Content()) { match := []byte("") newcontent = bytes.Replace(ct.Content(), match, replace, -1) diff --git a/transform/livereloadinject_test.go b/transform/livereloadinject_test.go new file mode 100644 index 000000000..605f65954 --- /dev/null +++ b/transform/livereloadinject_test.go @@ -0,0 +1,20 @@ +package transform + +import ( + "bytes" + "github.com/spf13/hugo/helpers" + "testing" +) + +func TestLiveReloadInject(t *testing.T) { + out := new(bytes.Buffer) + in := helpers.StringToReader("") + + tr := NewChain(LiveReloadInject) + tr.Apply(out, in, []byte("path")) + + expected := `` + if string(out.Bytes()) != expected { + t.Errorf("Expected %s got %s", expected, string(out.Bytes())) + } +}