Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __parse_host(host)
uri = URI.parse(host)

# Handle when port is not specified
if host =~ /^#{uri.scheme}:\/\/#{uri.host}$/
if uri.port == uri.default_port
port = nil
else
port = uri.port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,46 @@
end
end

context 'when there is one host with a protocol and no port' do

let(:host) do
['http://myhost']
end

it 'extracts the host' do
expect(hosts[0][:host]).to eq('myhost')
expect(hosts[0][:protocol]).to eq('http')
expect(hosts[0][:port]).to be(9200)
end
end

context 'when there is one host with a scheme, protocol and no port' do

let(:host) do
['https://myhost']
end

it 'extracts the host' do
expect(hosts[0][:host]).to eq('myhost')
expect(hosts[0][:protocol]).to eq('https')
expect(hosts[0][:port]).to be(9200)
end
end

context 'when there is one host with a scheme, protocol and no port' do

let(:host) do
['http://myhost/foo/bar']
end

it 'extracts the host' do
expect(hosts[0][:host]).to eq('myhost')
expect(hosts[0][:protocol]).to eq('http')
expect(hosts[0][:port]).to be(9200)
expect(hosts[0][:path]).to eq("/foo/bar")
end
end

context 'when there is more than one host' do

let(:host) do
Expand Down Expand Up @@ -939,4 +979,4 @@
end
end
end
end
end