Set release details for 0.2.13
[quvi.git] / share / lua / website / quvi / util.lua
blobbd3ff6ffbb7b3c29737bc9ecc16c875ee365f8be
2 -- quvi
3 -- Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com>
4 --
5 -- This file is part of quvi <http://quvi.sourceforge.net/>.
6 --
7 -- This library is free software; you can redistribute it and/or
8 -- modify it under the terms of the GNU Lesser General Public
9 -- License as published by the Free Software Foundation; either
10 -- version 2.1 of the License, or (at your option) any later version.
12 -- This library is distributed in the hope that it will be useful,
13 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 -- Lesser General Public License for more details.
17 -- You should have received a copy of the GNU Lesser General Public
18 -- License along with this library; if not, write to the Free Software
19 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 -- 02110-1301 USA
23 local M = {}
25 -- http://www.lua.org/pil/20.3.html
26 function M.decode (s)
27 r = {}
28 for n,v in s:gfind ("([^&=]+)=([^&=]+)") do
29 n = M.unescape (n)
30 r[n] = v
31 end
32 return r
33 end
35 -- http://www.lua.org/pil/20.3.html
36 function M.unescape (s)
37 s = s:gsub ('+', ' ')
38 s = s:gsub ('%%(%x%x)', function (h)
39 return string.char (tonumber (h, 16))
40 end)
41 return s
42 end
44 return M
46 -- vim: set ts=4 sw=4 tw=72 expandtab: