diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index 38caf18..17e9a27 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -20,7 +20,7 @@ module Rack body.each do |line| if line[''] - src = LIVERELOAD_JS_PATH + src = LIVERELOAD_JS_PATH.dup src << "?host=#{env['HTTP_HOST'].gsub(%r{:.*}, '')}" if env['HTTP_HOST'] line.gsub!('', %{}) diff --git a/spec/rack/livereload_spec.rb b/spec/rack/livereload_spec.rb index 5f8c5a8..8bafd88 100644 --- a/spec/rack/livereload_spec.rb +++ b/spec/rack/livereload_spec.rb @@ -27,6 +27,9 @@ describe Rack::LiveReload do app.stubs(:call).with(env).returns([ 200, { 'Content-Type' => 'text/html', 'Content-Length' => 0 }, [ '' ] ]) end + let(:host) { 'host' } + let(:env) { { 'HTTP_HOST' => host } } + let(:ret) { middleware.call(env) } let(:body) { ret.last.join } let(:length) { ret[1]['Content-Length'] } @@ -36,6 +39,8 @@ describe Rack::LiveReload do body.should include(described_class::LIVERELOAD_JS_PATH) length.should == body.length.to_s + + described_class::LIVERELOAD_JS_PATH.should_not include(host) end end