lua-resty-ada implements a LuaJIT FFI bindings to Ada — WHATWG-compliant and fast URL parser.
This library is considered production ready.
local ada = require("resty.ada")
local url = assert(ada.parse("https://www.7‑Eleven.com:1234/Home/../Privacy/Montréal"))
print(tostring(url))
-- prints: https://www.xn--7eleven-506c.com:1234/Privacy/Montr%C3%A9al
print(tostring(url:clear_port())) -- there are many more methods
-- prints: https://www.xn--7eleven-506c.com/Privacy/Montr%C3%A9al
url:free()
-- explicitly frees the memory without waiting for the garbage collector
-- There is also a static API
print(ada.get_href("https://www.7‑Eleven.com:1234/Home/../Privacy/Montréal"))
-- prints: https://www.xn--7eleven-506c.com:1234/Privacy/Montr%C3%A9al
print(ada.clear_port("https://www.7‑Eleven.com:1234/Home/../Privacy/Montréal"))
-- prints: https://www.xn--7eleven-506c.com/Privacy/Montr%C3%A9al
LDoc generated API docs can be viewed at bungle.github.io/lua-resty-ada.
❯ opm get bungle/lua-resty-ada
OPM repository for lua-resty-ada
is located at
opm.openresty.org/package/bungle/lua-resty-ada.
❯ luarocks install lua-resty-ada
LuaRocks repository for lua-resty-ada
is located at
luarocks.org/modules/bungle/lua-resty-ada.
Please consult Ada on how to build or install
the ada library. The Ada library needs to installed in in the system library path or
one of the paths in Lua's package.cpath
.
This project can also build it by executing (requires cmake):
❯ make build
Or run the test suite with act:
❯ act
lua-resty-ada
uses two clause BSD license.
Copyright (c) 2024 Aapo Talvensaari, 2024 Guilherme Salazar
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES