Fix for "head" and "header" tag confusion #19

Merged
matthewlehner merged 1 commits from head_tag_only into master 2012-12-14 00:08:58 +00:00
2 changed files with 12 additions and 1 deletions
Showing only changes of commit cc1ad71a62 - Show all commits

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)