Skip to content

Commit

Permalink
Always convert visit's URL to a String before manipulation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shepmaster committed Jul 8, 2014
1 parent 10e8450 commit 013c760
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/capybara/session.rb
Expand Up @@ -204,17 +204,18 @@ def current_url
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)
Expand Down

0 comments on commit 013c760

Please sign in to comment.