mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Route parameters have more precedence than query string arguments
This commit is contained in:
		
							parent
							
								
									8b1447b68d
								
							
						
					
					
						commit
						77356f7f43
					
				
					 2 changed files with 11 additions and 1 deletions
				
			
		|  | @ -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| | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue