4d6f285d
zhouhaihai
增加发布功能
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
local url = {}
local function decode_func(c)
return string.char(tonumber(c, 16))
end
local function decode(str)
local str = str:gsub('+', ' ')
return str:gsub("%%(..)", decode_func)
end
function url.parse(u)
local path,query = u:match "([^?]*)%??(.*)"
if path then
path = decode(path)
end
return path, query
end
function url.parse_query(q)
local r = {}
for k,v in q:gmatch "(.-)=([^&]*)&?" do
r[decode(k)] = decode(v)
end
return r
end
return url
|