Make sure to rewrite relative paths to absolute before setting “authority”.

Since version 2.1.2 of addressable gem, having an “authority” on the URI
(user, password, userinfo, host, port) with a relative path is an error and
an exception is thrown (see Issue 1), to avoid that make the path absolute
before setting host, port and scheme.
This commit is contained in:
Diego Elio 'Flameeyes' Pettenò 2010-04-30 18:54:30 +02:00
parent 67e2f47cc2
commit 66d532207d

View File

@ -173,12 +173,12 @@ module Faraday
#
def build_url(url, params = nil)
uri = URI.parse(url.to_s)
uri.host ||= @host
uri.port ||= @port
uri.scheme ||= @scheme
if @path_prefix && uri.path !~ /^\//
uri.path = "#{@path_prefix.size > 1 ? @path_prefix : nil}/#{uri.path}"
end
uri.host ||= @host
uri.port ||= @port
uri.scheme ||= @scheme
replace_query(uri, params)
uri
end