Skip to content

Commit

Permalink
Handle IPv6 address String on Faraday::Connection#proxy_from_env (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmo0920 committed Mar 22, 2021
1 parent 118f896 commit 850155e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faraday/connection.rb
Expand Up @@ -577,7 +577,7 @@ def proxy_from_env(url)
case url
when String
uri = Utils.URI(url)
uri = URI.parse("#{uri.scheme}://#{uri.hostname}").find_proxy
uri = URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
when URI
uri = url.find_proxy
when nil
Expand Down
7 changes: 7 additions & 0 deletions spec/faraday/connection_spec.rb
Expand Up @@ -18,6 +18,13 @@
it { expect(subject.path_prefix).to eq('/fish') }
it { expect(subject.params).to eq('a' => '1') }
end

context 'with IPv6 address' do
let(:address) { 'http://[::1]:85/' }

it { expect(subject.host).to eq('[::1]') }
it { expect(subject.port).to eq(85) }
end
end

shared_examples 'default connection options' do
Expand Down

0 comments on commit 850155e

Please sign in to comment.