mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Fix parsing JSON params when "charset" is present in "Content-Type" header (#193)
Resolves case when `Content-Type` headers is passed in form of `application/json; charset=utf-8`
This commit is contained in:
parent
d4e96c7b44
commit
28859fbdb8
2 changed files with 15 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
|
||||
# like params["_json"]
|
||||
def parse_json
|
||||
return unless @request.body && @request.headers["Content-Type"]? == APPLICATION_JSON
|
||||
return unless @request.body && @request.headers["Content-Type"]?.try(&.[APPLICATION_JSON]?)
|
||||
|
||||
body = @request.body.as(String)
|
||||
case json = JSON.parse(body).raw
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue