Is there an open source lua routine to decode query arguments conforming to RFC 3986? Specifically query arguments can be split by a ; or & i.e. field=value&field1=value1. How does one get to know if a particular query argument is separated by a i.e field=value;field1=value1. I can probably scan for the the token but apparently the field and value may also contain a ;. Since this is an often used functionality, I was wondering if there is a Lua library that will take care of all the corner cases.
Asked
Active
Viewed 605 times
1
-
May be helpful: http://stackoverflow.com/q/24885743/1847592 – Egor Skriptunoff Aug 19 '14 at 18:55
1 Answers
0
You can use the url
namespace in Luasocket module to parse URLs. The documentation is available here.
A sample code (and output) would be like:
> l = require 'socket.url'
> x = 'https://mail.google.com/mail/u/0/?ui=2&pli=1#inbox'
> z = l.parse(x)
> for k, v in pairs(z) do print(k,v) end
host mail.google.com
fragment inbox
query ui=2&pli=1
scheme https
path /mail/u/0/
authority mail.google.com

hjpotter92
- 78,589
- 36
- 144
- 183