mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Use String#starts_with? instead of String#[]? (#194)
It shows real intention and covers cases when `application/json` is passed in the middle of the string, like `some_garbage_string; application/json`
This commit is contained in:
		
							parent
							
								
									28859fbdb8
								
							
						
					
					
						commit
						a6678f6622
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		|  | @ -55,7 +55,7 @@ module Kemal | ||||||
|     # If request body is a JSON Array it's added into `params` as `_json` and can be accessed |     # If request body is a JSON Array it's added into `params` as `_json` and can be accessed | ||||||
|     # like params["_json"] |     # like params["_json"] | ||||||
|     def parse_json |     def parse_json | ||||||
|       return unless @request.body && @request.headers["Content-Type"]?.try(&.[APPLICATION_JSON]?) |       return unless @request.body && @request.headers["Content-Type"]?.try(&.starts_with?(APPLICATION_JSON)) | ||||||
| 
 | 
 | ||||||
|       body = @request.body.as(String) |       body = @request.body.as(String) | ||||||
|       case json = JSON.parse(body).raw |       case json = JSON.parse(body).raw | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue