This library provides low-level bindings and a high-level wrapper over ada-url, a high-performance and WHATWG-compliant URL parser written in C++.
The high-level wrapper manages memory for you via ORC move semantics.
Documentation for this library can be found here.
This library has been tested and confirmed to work with ada-url 3.2.1
To add this library to your project, run the following command:
$ nimble add ada
If you simply wish to install it, run this command:
$ nimble install ada
import std/options
import pkg/ada
var url = parseURL("https://example.com/path?x=y")
echo url.hostname ## example.com
echo url.pathname ## /path?x=y
echo url.query.get() ## ?x=y
import pkg/ada
let
urls = [
"https://github.com",
"https://lk.m.e,3.,ao????2.s.", # <--- These are technically valid URLs,
"mxl:://///dmnems.xyie", # <--- as the WhatWG URL spec is very forgiving for erroneous inputs.
"https://google.com",
"....", # <--- However, these two are not.
";:@;3!..//1@#;21" # <---
]
for url in urls:
echo '[' & url & "]: " & (
if isValidURL(url):
"valid"
else:
"invalid"
)