webrat/lib/merb_support/param_parser.rb
2008-04-16 10:54:37 +01:00

17 lines
451 B
Ruby

module Webrat
class ParamParser
def self.parse_query_parameters(query_string)
return {} if query_string.blank?
pairs = query_string.split('&').collect do |chunk|
next if chunk.empty?
key, value = chunk.split('=', 2)
next if key.empty?
value = value.nil? ? nil : CGI.unescape(value)
[ CGI.unescape(key), value ]
end.compact
UrlEncodedPairParser.new(pairs).result
end
end
end