diff --git a/lib/rack/query_parser.rb b/lib/rack/query_parser.rb index dbbb18e5a..cbde13cfd 100644 --- a/lib/rack/query_parser.rb +++ b/lib/rack/query_parser.rb @@ -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] ||= [] diff --git a/test/spec_utils.rb b/test/spec_utils.rb index 428abbfd7..d06a3c715 100644 --- a/test/spec_utils.rb +++ b/test/spec_utils.rb @@ -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"). @@ -174,7 +174,7 @@ def assert_nested_query(exp, act) Rack::Utils.parse_nested_query("foo[]=bar&foo[=baz"). must_equal "foo" => ["bar"], "foo[" => "baz" Rack::Utils.parse_nested_query("foo[]=bar&foo[]"). - must_equal "foo" => ["bar", nil] + must_equal "foo" => ["bar"] Rack::Utils.parse_nested_query("foo[]=bar&foo[]="). must_equal "foo" => ["bar", ""]