mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-08 00:03:41 -04:00
fix uri building issue where host/port should be specified before scheme
This commit is contained in:
parent
4d266f42b6
commit
403ea34529
@ -137,9 +137,9 @@ module Faraday
|
||||
#
|
||||
def build_url(url, params = nil)
|
||||
uri = URI.parse(url.to_s)
|
||||
uri.scheme ||= @scheme
|
||||
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
|
||||
|
@ -139,16 +139,20 @@ class TestConnection < Faraday::TestCase
|
||||
assert_no_match /token=abc/, url.query
|
||||
end
|
||||
|
||||
def test_build_url_parses_url_into_host
|
||||
def test_build_url_parses_url
|
||||
conn = Faraday::Connection.new
|
||||
uri = conn.build_url("http://sushi.com/sake.html")
|
||||
assert_equal "sushi.com", uri.host
|
||||
assert_equal "http", uri.scheme
|
||||
assert_equal "sushi.com", uri.host
|
||||
assert_equal '/sake.html', uri.path
|
||||
assert_nil uri.port
|
||||
end
|
||||
|
||||
def test_build_url_parses_url_into_port
|
||||
conn = Faraday::Connection.new
|
||||
uri = conn.build_url("http://sushi.com/sake.html")
|
||||
assert_nil uri.port
|
||||
def test_build_url_parses_url_and_changes_scheme
|
||||
conn = Faraday::Connection.new :url => "http://sushi.com/sushi"
|
||||
conn.scheme = 'https'
|
||||
uri = conn.build_url("sake.html")
|
||||
assert_equal 'https://sushi.com/sushi/sake.html', uri.to_s
|
||||
end
|
||||
|
||||
def test_params_to_query_converts_hash_of_params_to_uri_escaped_query_string
|
||||
|
Loading…
x
Reference in New Issue
Block a user