Skip to content

Commit 20bd5d5

Browse files
committed
fix: Allow for multiple values for a parameter
1 parent 2b45ad9 commit 20bd5d5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/ruby_http_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def add_version(url = nil)
8484
# - The url string with the query parameters appended
8585
#
8686
def build_query_params(url, query_params)
87-
params = query_params.map { |key, value| "#{key}=#{value}" }.join('&')
87+
params = URI.encode_www_form(query_params)
8888
url.concat("?#{params}")
8989
end
9090

test/test_ruby_http_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def test_add_version
6161

6262
def test_build_query_params
6363
url = ''
64-
query_params = { 'limit' => 100, 'offset' => 0 }
64+
query_params = { 'limit' => 100, 'offset' => 0, 'categories' => ['category1', 'category2'] }
6565
url = @client.build_query_params(url, query_params)
66-
assert_equal('?limit=100&offset=0', url)
66+
assert_equal('?limit=100&offset=0&categories=category1&categories=category2', url)
6767
end
6868

6969
def test_build_url

0 commit comments

Comments
 (0)