mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-30 00:03:09 -04:00
Faraday::Connection#build_url doesnt add an ending slash to urls
This commit is contained in:
parent
2ce28e9a81
commit
e61e92b9ee
@ -217,7 +217,9 @@ module Faraday
|
||||
def build_url(url, extra_params = nil)
|
||||
uri = URI.parse(url.to_s)
|
||||
if @path_prefix && uri.path !~ /^\//
|
||||
uri.path = "#{@path_prefix.size > 1 ? @path_prefix : nil}/#{uri.path}"
|
||||
new_path = @path_prefix.size > 1 ? @path_prefix.dup : ''
|
||||
new_path << "/#{uri.path}" unless uri.path.empty?
|
||||
uri.path = new_path
|
||||
end
|
||||
uri.host ||= @host
|
||||
uri.port ||= @port
|
||||
|
@ -147,6 +147,13 @@ class TestConnection < Faraday::TestCase
|
||||
assert_equal '/sake.html', uri.path
|
||||
end
|
||||
|
||||
def test_build_url_doesnt_add_ending_slash
|
||||
conn = Faraday::Connection.new
|
||||
conn.url_prefix = "http://sushi.com/nigiri"
|
||||
uri = conn.build_url(nil)
|
||||
assert_equal "/nigiri", uri.path
|
||||
end
|
||||
|
||||
def test_build_url_parses_url_params_into_query
|
||||
conn = Faraday::Connection.new
|
||||
uri = conn.build_url("http://sushi.com/sake.html", 'a[b]' => '1 + 2')
|
||||
|
Loading…
x
Reference in New Issue
Block a user