ensure some sort of host for rack::mockrequests that don't provide one

This commit is contained in:
John Bintz 2011-11-28 10:42:39 -05:00
parent 1e884ba174
commit d4c8e8cf96
2 changed files with 9 additions and 1 deletions

View File

@ -54,7 +54,7 @@ module Rack
body.each do |line| body.each do |line|
if !headers['X-Rack-LiveReload'] && line['</head>'] if !headers['X-Rack-LiveReload'] && line['</head>']
host_to_use = @options[:host] || env['HTTP_HOST'].gsub(%r{:.*}, '') host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '')
if use_vendored? if use_vendored?
src = LIVERELOAD_JS_PATH.dup + "?host=#{host_to_use}" src = LIVERELOAD_JS_PATH.dup + "?host=#{host_to_use}"

View File

@ -124,6 +124,14 @@ describe Rack::LiveReload do
body.should_not include('web_socket') body.should_not include('web_socket')
end end
end end
context 'no host at all' do
let(:env) { {} }
it 'should use localhost' do
body.should include('localhost')
end
end
end end
context '/__rack/livereload.js' do context '/__rack/livereload.js' do