Skip to content

Commit

Permalink
Update URL param encoding to use CGI (#232)
Browse files Browse the repository at this point in the history
* Update URL param encoding to use CGI (#229)

* Add MAP parameters for line items

* Update license to 2020

* Bump version

* fixes #227 by using CGI for url param encoding

* fix up code quality
  • Loading branch information
osowskit authored Sep 25, 2020
1 parent df2c945 commit 94fc4c6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/twitter-ads/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,17 @@ def oauth_request
Response.new(response.code, response.each {}, response.body)
end

def escape_params(input)
input.map do |key, value|
"#{CGI.escape key.to_s}=#{CGI.escape value.to_s}"
end.join('&')
end

def http_request
request_url = @resource

if @options[:params] && !@options[:params].empty?
request_url += "?#{URI.encode_www_form(@options[:params])}"
request_url += "?#{escape_params(@options[:params])}"
end

request = HTTP_METHOD[@method].new(request_url)
Expand Down

0 comments on commit 94fc4c6

Please sign in to comment.