1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Simplify query_params

This commit is contained in:
Evan Phoenix 2011-09-23 23:30:10 -07:00
parent 340d2fbf8e
commit 2b9484c896

View file

@ -23,10 +23,12 @@ module Puma
# parameter (which defaults to '&;'. # parameter (which defaults to '&;'.
def self.query_parse(qs, d = '&;') def self.query_parse(qs, d = '&;')
params = {} params = {}
(qs||'').split(/[#{d}] */n).inject(params) { |h,p|
k, v=unescape(p).split('=',2) qs.split(/[#{d}] */n).each do |p|
k, v = unescape(p).split('=', 2)
if cur = params[k] if cur = params[k]
if cur.class == Array if cur.kind_of? Array
params[k] << v params[k] << v
else else
params[k] = [cur, v] params[k] = [cur, v]
@ -34,7 +36,7 @@ module Puma
else else
params[k] = v params[k] = v
end end
} end
return params return params
end end