lib/stripe/util.rb in stripe-1.27.2 vs lib/stripe/util.rb in stripe-1.28.0

- old
+ new

@@ -1,5 +1,7 @@ +require "webrick" + module Stripe module Util def self.objects_to_ids(h) case h when APIResource @@ -91,10 +93,13 @@ object end end def self.url_encode(key) - URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) + # Unfortunately, URI.escape was deprecated. Here we use a method from + # WEBrick instead given that it's a fairly close approximation (credit to + # the AWS Ruby SDK for coming up with the technique). + WEBrick::HTTPUtils.escape(key.to_s).gsub('%5B', '[').gsub('%5D', ']') end def self.flatten_params(params, parent_key=nil) result = [] params.each do |key, value|