Skip to content

Commit d3cde4f

Browse files
committed
migrate from URI.encode to CGI::escape to become ruby 3 ready
1 parent 6433671 commit d3cde4f

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/woocommerce_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def add_query_params endpoint, data
9797

9898
endpoint += "?" unless endpoint.include? "?"
9999
endpoint += "&" unless endpoint.end_with? "?"
100-
endpoint + URI.encode(flatten_hash(data).join("&"))
100+
endpoint + CGI::escape(flatten_hash(data).join("&"))
101101
end
102102

103103
# Internal: Get URL for requests

lib/woocommerce_api/oauth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_oauth_url
4242
params["oauth_timestamp"] = Time.new.to_i
4343
params["oauth_signature"] = CGI::escape(generate_oauth_signature(params, url))
4444

45-
query_string = URI::encode(params.map{|key, value| "#{key}=#{value}"}.join("&"))
45+
query_string = CGI::escape(params.map{|key, value| "#{key}=#{value}"}.join("&"))
4646

4747
"#{url}?#{query_string}"
4848
end

test/test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_oauth_put
155155

156156
def test_adding_query_params
157157
url = @oauth.send(:add_query_params, 'foo.com', filter: { sku: '123' }, order: 'created_at')
158-
assert_equal url, URI.encode('foo.com?filter[sku]=123&order=created_at')
158+
assert_equal url, CGI::escape('foo.com?filter[sku]=123&order=created_at')
159159
end
160160

161161
def test_invalid_signature_method

0 commit comments

Comments
 (0)