Method: Rack::QueryParser#parse_nested_query

Defined in:
lib/rack/query_parser.rb

#parse_nested_query(qs, separator = nil) ⇒ Object

parse_nested_query expands a query string into structural types. Supported types are Arrays, Hashes and basic value types. It is possible to supply query strings with parameters of conflicting types, in this case a ParameterTypeError is raised. Users are encouraged to return a 400 in this case.


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rack/query_parser.rb', line 72

def parse_nested_query(qs, separator = nil)
  params = make_params

  unless qs.nil? || qs.empty?
    (qs || '').split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
      k, v = p.split('=', 2).map! { |s| unescape(s) }

      _normalize_params(params, k, v, 0)
    end
  end

  return params.to_h
rescue ArgumentError => e
  raise InvalidParameterError, e.message, e.backtrace
end