Route parameters have more precedence than query string arguments

This commit is contained in:
Juan Wajnerman 2015-05-29 18:24:31 -03:00
parent 8b1447b68d
commit 77356f7f43
2 changed files with 11 additions and 1 deletions

View file

@ -21,6 +21,16 @@ describe "Frank::Handler" do
response.body.should eq("hello world")
end
it "route parameter has more precedence than query string arguments" do
frank = Frank::Handler.new
frank.add_route "GET", "/:message" do |ctx|
"hello #{ctx.params["message"]}"
end
request = HTTP::Request.new("GET", "/world?message=coco")
response = frank.call(request)
response.body.should eq("hello world")
end
it "sets content type" do
frank = Frank::Handler.new
frank.add_route "GET", "/" do |env|

View file

@ -25,7 +25,7 @@ class Frank::Handler < HTTP::Handler
if params
if query = uri.query
CGI.parse(query) do |key, value|
params[key] = value
params[key] ||= value
end
end