Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/api_client_builder/url_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(domain)
#
# @return [URI] the fully built route
def build_route(route, **params)
string_params = route.split(%r{[\/=&]}).select { |param| param.start_with?(':') }
string_params = route.split(%r{[\/?=&]}).select { |param| param.start_with?(':') }
symboled_params = string_params.map { |param| param.tr(':', '').to_sym }

new_route = route.clone
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/api_client_builder/url_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ module APIClientBuilder
end
end

context "the route has URL param just after a colon params path" do
let(:url) { 'objects/:object_id?foo=bar' }
let(:url_generator) { URLGenerator.new('https://www.domain.com/api/endpoints/') }

subject do
route = url_generator.build_route(url, object_id: 1)
end

it do
is_expected.to eq URI.parse('https://www.domain.com/api/endpoints/objects/1?foo=bar')
end
end

end

context 'route with colon params and non matching keys' do
Expand Down