Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection: Handle IPv6 address String on #proxy_from_env #1252

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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