1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Always convert visit's URL to a String before manipulation

It is convenient to be able to pass in URI objects to `visit`, but
these need to be coerced to a string before actual usage. Most of
visit's code paths would convert the incoming url to a string
as-needed. However, the path used when `always_include_port` is
enabled did not, causing an error where `URI.parse` would try to parse
an existing URI object.

This change consolidates the coercion to string at the entrypoint of
the method.
This commit is contained in:
Jake Goulding 2014-07-08 09:35:00 -07:00
parent 10e8450429
commit 013c76036b

View file

@ -204,17 +204,18 @@ module Capybara
def visit(url)
raise_server_error!
url = url.to_s
@touched = true
url_relative = URI.parse(url.to_s).scheme.nil?
url_relative = URI.parse(url).scheme.nil?
if url_relative && Capybara.app_host
url = Capybara.app_host + url.to_s
url = Capybara.app_host + url
url_relative = false
end
if @server
url = "http://#{@server.host}:#{@server.port}" + url.to_s if url_relative
url = "http://#{@server.host}:#{@server.port}" + url if url_relative
if Capybara.always_include_port
uri = URI.parse(url)