Merge pull request #19 from matthewlehner/head_tag_only

Fix for "head" and "header" tag confusion
This commit is contained in:
John Bintz 2012-12-13 16:08:58 -08:00
commit 6f9576215a
2 changed files with 12 additions and 1 deletions

View File

@ -77,7 +77,7 @@ module Rack
template = ERB.new(::File.read(::File.expand_path('../../../skel/livereload.html.erb', __FILE__)))
if line['<head']
line.gsub!(/<head[^>]*>/) { |match| %{#{match}#{template.result(binding)}} }
line.gsub!(/<head([^(er)]|\s)[^>]*>/) { |match| %{#{match}#{template.result(binding)}} }
end
headers["X-Rack-LiveReload"] = '1'

View File

@ -107,6 +107,17 @@ describe Rack::LiveReload do
end
end
context 'in header tags' do
let(:page_html) { "<header class='hero'><h1>Just a normal header tag</h1></header>" }
let(:body_dom) { Nokogiri::XML(body) }
it 'should not add the livereload js' do
body_dom.at_css("header")[:class].should == 'hero'
body_dom.css('script').should be_empty
end
end
context 'not vendored' do
before do
middleware.stubs(:use_vendored?).returns(false)