Skip to content

Commit 4205e06

Browse files
authored
Merge pull request #62 from ifad/bugfix/squeeze-double-slashes
Squeeze multiple slashes in URLs
2 parents 27d3d28 + bd07aa2 commit 4205e06

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.byebug_history
12
/.bundle/
23
/.yardoc
34
/coverage/

lib/hawk/http.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def request(method, path, options)
116116
private
117117

118118
def build_url(path)
119-
base.merge(path.sub(%r{^/}, '')).to_s
119+
base.merge(path.delete_prefix('/').squeeze('/')).to_s
120120
end
121121

122122
def response_handler(response)

lib/hawk/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Hawk
4-
VERSION = '2.0.0'
4+
VERSION = '3.0.0'
55
end

spec/basic_operations_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ class Person < Hawk::Model::Base
2222
}
2323
end
2424

25+
describe '.get' do
26+
it 'squeezes multiple slashes' do
27+
stub_request(:GET, 'https://example.org/people/batch/id')
28+
.with(headers: { 'User-Agent' => 'Foobar' })
29+
.to_return(status: 200, body: [2].to_json, headers: {})
30+
31+
expect(Person.get('/batch///id')).to contain_exactly(2)
32+
end
33+
end
34+
2535
describe '.find(id)' do
2636
specify do
2737
stub_request(:GET, 'https://example.org/people/2')

0 commit comments

Comments
 (0)