bugfix, parsing http array form (#1852)

This commit is contained in:
t0350
2024-01-12 18:10:36 +08:00
committed by GitHub
parent b309d82538
commit 6bdc8b8608
2 changed files with 26 additions and 1 deletions

View File

@@ -20,7 +20,17 @@ end
function url.parse_query(q)
local r = {}
for k,v in q:gmatch "(.-)=([^&]*)&?" do
r[decode(k)] = decode(v)
local dk, dv = decode(k), decode(v)
local oldv = r[dk]
if oldv then
if type(oldv) ~= "table" then
r[dk] = {oldv, dv}
else
oldv[#oldv+1] = dv
end
else
r[dk] = dv
end
end
return r
end