Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Merge pull request #813 from eileencodes/remove-check-for-nil"
Add a test demonstrating that `nil` is treated as an empty query string

This reverts commit 7788a1b, reversing
changes made to e117591.
  • Loading branch information
jeremy committed Mar 5, 2015
1 parent 1a43de5 commit 0575eb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/utils.rb
Expand Up @@ -110,7 +110,7 @@ def parse_query(qs, d = nil, &unescaper)
# ParameterTypeError is raised. Users are encouraged to return a 400 in this
# case.
def parse_nested_query(qs, d = nil)
return {} if qs.empty?
return {} if qs.nil? || qs.empty?
params = KeySpaceConstrainedParams.new

(qs || '').split(d ? (COMMON_SEP[d] || /[#{d}] */n) : DEFAULT_SEP).each do |p|
Expand Down
4 changes: 4 additions & 0 deletions test/spec_utils.rb
Expand Up @@ -134,6 +134,10 @@ def kcodeu
}.should.not.raise
end

should "parse nil as an empty query string" do
Rack::Utils.parse_nested_query(nil).should.equal({})
end

should "parse nested query strings correctly" do
Rack::Utils.parse_nested_query("foo").
should.equal "foo" => nil
Expand Down

0 comments on commit 0575eb9

Please sign in to comment.