Refactor parse_url_params

This commit is contained in:
sdogruyol 2016-01-13 10:07:37 +02:00
parent d0b62cc728
commit 4c423e967f

View file

@ -35,18 +35,15 @@ class Kemal::ParamParser
parse_part(@request.query) parse_part(@request.query)
end end
# Ditto: This needs memoization without the huge AllParamTypes union :|
def parse_url_params def parse_url_params
url_params = @request.url_params if @request.url_params
begin url_params = @request.url_params.not_nil!
url_params = url_params.not_nil!
name_table = url_params.regex.name_table name_table = url_params.regex.name_table
size = url_params.size url_params.size.times do |i|
size.times do |i| name = (name_table.fetch(i + 1) { i + 1 }) as String
name = name_table.fetch(i + 1) { i + 1 } @params[name] = url_params[i + 1]
value = url_params[i + 1]
@params[name as String] = value
end end
rescue
end end
end end