mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Replace implementation with more appropriate URI.unescape (#231)
This commit is contained in:
parent
e43b2a3a01
commit
375259f34c
1 changed files with 6 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
require "json"
|
||||
require "uri"
|
||||
|
||||
module Kemal
|
||||
# ParamParser parses the request contents including query_params and body
|
||||
|
@ -21,8 +22,10 @@ module Kemal
|
|||
@json_parsed = false
|
||||
end
|
||||
|
||||
private def decode_url_param(value : String)
|
||||
value.size == 0 ? value : HTTP::Params.parse(value).first[0]?
|
||||
private def unescape_url_param(value : String)
|
||||
value.size == 0 ? value : URI.unescape(value)
|
||||
rescue
|
||||
value
|
||||
end
|
||||
|
||||
{% for method in %w(url query body json) %}
|
||||
|
@ -49,7 +52,7 @@ module Kemal
|
|||
def parse_url
|
||||
if params = @request.url_params
|
||||
params.each do |key, value|
|
||||
@url[key.as(String)] = decode_url_param(value).as(String)
|
||||
@url[key.as(String)] = unescape_url_param(value).as(String)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue