From ef4dfcec6cf17308e2816ef29801f01c3cf6fcbb Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Wed, 14 Oct 2015 00:41:54 -0700 Subject: Load livereload.js from "/" Fix #1406 Instead of loading the file from http://localhost:port/, it can be loaded from /. --- transform/livereloadinject.go | 9 ++------- transform/livereloadinject_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 transform/livereloadinject_test.go (limited to 'transform') 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())) + } +} -- cgit v1.2.3