Fixes for head tag regex #21

Merged
matthewlehner merged 2 commits from head_tag_only into master 2012-12-14 14:28:52 +00:00
Showing only changes of commit 706d158328 - Show all commits

View File

@ -4,6 +4,7 @@ module Rack
class LiveReload class LiveReload
LIVERELOAD_JS_PATH = '/__rack/livereload.js' LIVERELOAD_JS_PATH = '/__rack/livereload.js'
LIVERELOAD_LOCAL_URI = 'http://localhost:35729/livereload.js' LIVERELOAD_LOCAL_URI = 'http://localhost:35729/livereload.js'
HEAD_TAG_REGEX = /<head>|<head[^(er)][^<]*>/
BAD_USER_AGENTS = [ %r{MSIE} ] BAD_USER_AGENTS = [ %r{MSIE} ]
@ -77,7 +78,7 @@ module Rack
template = ERB.new(::File.read(::File.expand_path('../../../skel/livereload.html.erb', __FILE__))) template = ERB.new(::File.read(::File.expand_path('../../../skel/livereload.html.erb', __FILE__)))
if line['<head'] if line['<head']
line.gsub!(/<head([^(er)]|\s)[^>]*>/) { |match| %{#{match}#{template.result(binding)}} } line.gsub!(HEAD_TAG_REGEX) { |match| %{#{match}#{template.result(binding)}} }
end end
headers["X-Rack-LiveReload"] = '1' headers["X-Rack-LiveReload"] = '1'