From f46df7791fee51ac82c4305bfb686f30d121be65 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 8 Nov 2010 10:09:46 +0000 Subject: [PATCH 1/2] Fix case where save_and_open_page was mangling URLs in self-closing elements. See https://github.com/jnicklas/capybara/issues/issue/188 --- lib/capybara/util/save_and_open_page.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/capybara/util/save_and_open_page.rb b/lib/capybara/util/save_and_open_page.rb index 29f4dfbf7..e5d9c337b 100644 --- a/lib/capybara/util/save_and_open_page.rb +++ b/lib/capybara/util/save_and_open_page.rb @@ -30,7 +30,7 @@ def rewrite_css_and_image_references(response_html) # :nodoc: list << name if File.directory?(name) and not name.to_s =~ /^\./ list end - response_html.gsub(/("|')\/(#{directories.join('|')})/, '\1' + Capybara.asset_root.to_s + '/\2') + response_html.gsub(/=("|')\/(#{directories.join('|')})/, '=\1' + Capybara.asset_root.to_s + '/\2') end end end From 721d6ef33f9dfa08c8d0211f672edd5ea98471b0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 8 Nov 2010 10:18:43 +0000 Subject: [PATCH 2/2] Replace inject with slightly more legible select --- lib/capybara/util/save_and_open_page.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/capybara/util/save_and_open_page.rb b/lib/capybara/util/save_and_open_page.rb index e5d9c337b..c817cf9d8 100644 --- a/lib/capybara/util/save_and_open_page.rb +++ b/lib/capybara/util/save_and_open_page.rb @@ -26,10 +26,9 @@ def open_in_browser(path) # :nodoc def rewrite_css_and_image_references(response_html) # :nodoc: return response_html unless Capybara.asset_root - directories = Dir.new(Capybara.asset_root).entries.inject([]) do |list, name| - list << name if File.directory?(name) and not name.to_s =~ /^\./ - list - end + directories = Dir.new(Capybara.asset_root).entries.select { |name| + File.directory?(name) and not name.to_s =~ /^\./ + } response_html.gsub(/=("|')\/(#{directories.join('|')})/, '=\1' + Capybara.asset_root.to_s + '/\2') end end