Method: Spider::HTTP.parse_query

Defined in:
lib/spiderfw/http/http.rb

.parse_query(qs, d = '&') ⇒ Object

Parameters

qs<String>

The query string.

d<String>

The query string divider. Defaults to “&”.

Returns

Mash

The parsed query string.

Examples

query_parse("bar=nik&post[body]=heya")
  # => { :bar => "nik", :post => { :body => "heya" } }

– from Merb



173
174
175
176
177
178
# File 'lib/spiderfw/http/http.rb', line 173

def self.parse_query(qs, d = '&')
  return (qs||'').split(/[#{d}] */n).inject({}) { |h,p| 
    key, value = urldecode(p).split('=',2)
    normalize_params(h, key, value)
  }
end