fork(2) download
  1. function urldecode(s)
  2. s = s:gsub('+', ' ')
  3. :gsub('%%(%x%x)', function(h)
  4. return string.char(tonumber(h, 16))
  5. end)
  6. return s
  7. end
  8.  
  9. function parseurl(s)
  10. local ans = {}
  11. for k,v in s:gmatch('([^&=?]-)=([^&=?]+)' ) do
  12. ans[ k ] = urldecode(v)
  13. end
  14. return ans
  15. end
  16.  
  17. local a = "http://w...content-available-to-author-only...e.com/test.html?key1=val1&key2=val2&key3=val3"
  18. t = parseurl(a)
  19. print(t.key1 )
  20. print(t.key2)
  21.  
Success #stdin #stdout 0s 14120KB
stdin
Standard input is empty
stdout
val1
val2