Skip to content

Commit

Permalink
Parsing behavior change from foo[] to "foo" => []
Browse files Browse the repository at this point in the history
Pending discussion in rack#1696 and if merged also fixes rack#1696
  • Loading branch information
PragTob committed Jul 21, 2020
1 parent 649c72b commit 11b5f8f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rack/query_parser.rb
Expand Up @@ -102,7 +102,7 @@ def normalize_params(params, name, v, depth)
elsif after == "[]"
params[k] ||= []
raise ParameterTypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
params[k] << v
params[k] << v unless v.nil?
elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$)
child_key = $1
params[k] ||= []
Expand Down
2 changes: 1 addition & 1 deletion test/spec_utils.rb
Expand Up @@ -162,7 +162,7 @@ def assert_nested_query(exp, act)
must_equal "pid=1234" => "1023", "a" => "b"

Rack::Utils.parse_nested_query("foo[]").
must_equal "foo" => [nil]
must_equal "foo" => []
Rack::Utils.parse_nested_query("foo[]=").
must_equal "foo" => [""]
Rack::Utils.parse_nested_query("foo[]=bar").
Expand Down

0 comments on commit 11b5f8f

Please sign in to comment.