Skip to content

Commit e38d574

Browse files
committed
improved url component parsing so that strings with spaces did not produce an invalid url error
1 parent 64cbd7b commit e38d574

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/ruby-stackoverflow/client.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'json'
2+
require 'uri'
23
require 'ruby-stackoverflow/client/response_data'
34
require 'ruby-stackoverflow/client/resource/resource'
45
require 'ruby-stackoverflow/client/resource/user'
@@ -56,8 +57,8 @@ def parse_response(data, klass)
5657
def append_params_to_url(url, options)
5758
url = Configuration.api_url + url
5859
options.merge!(key_params)
59-
options = options.to_a.map{|k,v|"#{k}=#{v}"}
60-
url+'?'+options.join('&')
60+
options = URI.encode_www_form(options)
61+
url+'?'+options
6162
end
6263

6364
def key_params

lib/ruby-stackoverflow/client/parse_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def parse_options(options = {})
1414
else
1515
options[k] = v
1616
end
17-
end
17+
end
1818
end
1919

2020
def join_ids(ids)

0 commit comments

Comments
 (0)