mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-06 00:03:36 -04:00
Merge relative url without escaping (#1569)
This commit is contained in:
parent
4abafa5c66
commit
d8bfca25fa
@ -473,7 +473,8 @@ module Faraday
|
||||
if url && !base.path.end_with?('/')
|
||||
base.path = "#{base.path}/" # ensure trailing slash
|
||||
end
|
||||
url = url.to_s.gsub(':', '%3A') if URI.parse(url.to_s).opaque
|
||||
# Ensure relative url will be parsed correctly (such as `service:search` )
|
||||
url = "./#{url}" if url.respond_to?(:start_with?) && !url.start_with?('http://', 'https://', '/', './', '../')
|
||||
uri = url ? base + url : base
|
||||
if params
|
||||
uri.query = params.to_query(params_encoder || options.params_encoder)
|
||||
|
@ -300,14 +300,14 @@ RSpec.describe Faraday::Connection do
|
||||
it 'joins url to base when used relative path' do
|
||||
conn = Faraday.new(url: url)
|
||||
uri = conn.build_exclusive_url('service:search?limit=400')
|
||||
expect(uri.to_s).to eq('http://service.com/service%3Asearch?limit=400')
|
||||
expect(uri.to_s).to eq('http://service.com/service:search?limit=400')
|
||||
end
|
||||
|
||||
it 'joins url to base when used with path prefix' do
|
||||
conn = Faraday.new(url: url)
|
||||
conn.path_prefix = '/api'
|
||||
uri = conn.build_exclusive_url('service:search?limit=400')
|
||||
expect(uri.to_s).to eq('http://service.com/api/service%3Asearch?limit=400')
|
||||
expect(uri.to_s).to eq('http://service.com/api/service:search?limit=400')
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user