minor cleanup

This commit is contained in:
Thomas Walpole 2018-10-16 16:06:50 -07:00
parent b03c934166
commit cc5111119d
2 changed files with 5 additions and 4 deletions

View File

@ -49,8 +49,9 @@ module Capybara
# #
def inject_asset_host(html, host: Capybara.asset_host) def inject_asset_host(html, host: Capybara.asset_host)
if host && Nokogiri::HTML(html).css('base').empty? if host && Nokogiri::HTML(html).css('base').empty?
match = html.match(/<head[^<]*?>/) html.match(/<head[^<]*?>/) do |m|
return html.clone.insert match.end(0), "<base href='#{host}' />" if match return html.clone.insert m.end(0), "<base href='#{host}' />"
end
end end
html html
end end

View File

@ -18,8 +18,8 @@ module Capybara
def resolves_for?(session) def resolves_for?(session)
uri = ::Addressable::URI.parse(session.current_url) uri = ::Addressable::URI.parse(session.current_url)
uri.query = nil if uri && options[:ignore_query] uri&.query = nil if options[:ignore_query]
@actual_path = options[:url] ? uri.to_s : uri&.request_uri @actual_path = options[:url] ? uri&.to_s : uri&.request_uri
if @expected_path.is_a? Regexp if @expected_path.is_a? Regexp
@actual_path.to_s.match(@expected_path) @actual_path.to_s.match(@expected_path)