-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
The obsolete method URI.encode
is used in the code which is throwing the error while using the gem with the latest Ruby versions e.g. ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux]
.
wc-api-ruby/lib/woocommerce_api.rb
Line 100 in 6433671
endpoint + URI.encode(flatten_hash(data).join("&")) |
The method was marked as obsolete many years back in 2009 with ruby/ruby@238b979
It can be replaced with the CGI.escape
method.
More details: https://bugs.ruby-lang.org/issues/17309
There are many more discussions around the topic on https://bugs.ruby-lang.org/
I have monkeypatched the method in my Rails app until the patch is available on this gem.
# config/initalizers/woo_commerce.rb
module WooCommerce
class API
# URI.encode (alias of URI.escape) method used in the gem's implementation
# is obsolete since 10 years and removed in Ruby 3.
# https://github.com/ruby/ruby/commit/238b979f1789f95262a267d8df6239806f2859cc
def add_query_params endpoint, data
return endpoint if data.nil? || data.empty?
endpoint += "?" unless endpoint.include? "?"
endpoint += "&" unless endpoint.end_with? "?"
endpoint + CGI.escape(flatten_hash(data).join("&"))
end
end
end
rodolfoburla, ricvillagrana and bond
Metadata
Metadata
Assignees
Labels
No labels