lib/openpay/utils/search_params.rb in openpay-2.0.0 vs lib/openpay/utils/search_params.rb in openpay-2.0.1
- old
+ new
@@ -1,15 +1,18 @@
require 'ostruct'
+require 'cgi'
module OpenpayUtils
class SearchParams < OpenStruct
#"?creation[gte]=2013-11-01&limit=2&amount[lte]=100"
def to_str
filter = '?'
self.marshal_dump.each do |attribute, value|
if attribute =~ /(\w+)_(gte|lte)/
- attribute = "#{$1}[#{$2}]"
+ square_bracket_open_encode = CGI.escape('[')
+ square_bracket_close_encode = CGI.escape(']')
+ attribute = "#{$1}#{square_bracket_open_encode}#{$2}#{square_bracket_close_encode}"
end
filter << "#{attribute}=#{value}&"
end
filter.sub(/\&$/, '')
end