Only inject JS into the first instance of <head>.
This commit is contained in:
parent
952ea670dd
commit
c52c5e1b42
@ -71,7 +71,7 @@ module Rack
|
|||||||
|
|
||||||
@new_body.each do |line|
|
@new_body.each do |line|
|
||||||
if !@livereload_added && line['<head']
|
if !@livereload_added && line['<head']
|
||||||
line.gsub!(HEAD_TAG_REGEX) { |match| %{#{match}#{template.result(binding)}} }
|
line.sub!(HEAD_TAG_REGEX) { |match| %{#{match}#{template.result(binding)}} }
|
||||||
|
|
||||||
@livereload_added = true
|
@livereload_added = true
|
||||||
end
|
end
|
||||||
|
@ -143,6 +143,14 @@ describe Rack::LiveReload::BodyProcessor do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'in inline javascript containing markup' do
|
||||||
|
let(:page_html) { '<head></head><script>var html="<head></head>";</script>' }
|
||||||
|
|
||||||
|
it 'should not add the livereload js' do
|
||||||
|
processed_body.should include('var html="<head></head>"')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'not vendored' do
|
context 'not vendored' do
|
||||||
before do
|
before do
|
||||||
processor.stubs(:use_vendored?).returns(false)
|
processor.stubs(:use_vendored?).returns(false)
|
||||||
|
Loading…
Reference in New Issue
Block a user