Permalink
Browse files

Use parse_nested_query for parsing URI as that's what Rack does

  • Loading branch information...
eugenebolshakov authored and brynary committed Sep 20, 2010
1 parent 815b35e commit ca19a0da0919a1d04c658db9b9e315976146e67b
Showing with 7 additions and 1 deletion.
  1. +1 −0 History.txt
  2. +1 −1 lib/rack/test.rb
  3. +5 −0 spec/rack/test_spec.rb
View
@@ -2,6 +2,7 @@
* Bug fixes
+ * Use parse_nested_query for parsing URI like Rack does (Eugene Bolshakov)
* Don't depend on ActiveSupport extension to String (Bryan Helmkamp)
* Do not overwrite HTTP_HOST if it is set (Krekoten' Marjan)
View
@@ -175,7 +175,7 @@ def env_for(path, env)
if env["REQUEST_METHOD"] == "GET"
params = env[:params] || {}
params = parse_nested_query(params) if params.is_a?(String)
- params.update(parse_query(uri.query))
+ params.update(parse_nested_query(uri.query))
uri.query = build_nested_query(params)
elsif !env.has_key?(:input)
env["CONTENT_TYPE"] ||= "application/x-www-form-urlencoded"
View
@@ -96,6 +96,11 @@
last_request.GET.should == { "baz" => "2", "foo" => { "bar" => "1" }}
end
+ it "parses query strings with repeated variable names correctly" do
+ request "/foo?bar=2&bar=3"
+ last_request.GET.should == { "bar" => "3" }
+ end
+
it "accepts raw input in params for GET requests" do
request "/foo?baz=2", :params => "foo[bar]=1"
last_request.GET.should == { "baz" => "2", "foo" => { "bar" => "1" }}

0 comments on commit ca19a0d

Please sign in to comment.