Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 903e6ada23
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (31 sloc) 1.369 kb

A Robust URL Parser and Builder

This small Lua library provides a few functions to parse URL with querystring and build new URL easily.

> url = require'neturl'

Querystring parser

The library supports brackets in querystrings, like PHP. It means you can use brackets to build multi-dimensional tables. The parsed querystring has a tostring() helper. As usual with Lua, if no index is specified, it starts from index 1.

> query = url.parseQuery("first=abc&a[]=123&a[]=false&b[]=str&c[]=3.5&a[]=last")
> = query
> = query.a[1]

URL parser

The library converts an URL to a table of the elements as described in RFC : scheme, host, path, etc.

> u = url.parse("")
> = u.scheme
> =
> = u.path

URL normalization

> = url.parse(""):normalize()

URL resolver

URL resolution follows the examples provided in the RFC 2396.

> = url.parse("http://a/b/c/d;p?q"):resolve("../../g")

Querystring builder

> u = url.parse("")
> = "bar"
> = u
Jump to Line
Something went wrong with that request. Please try again.