1

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.

doon
  • 2,311
  • 7
  • 31
  • 52

1 Answers1

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