larzurl
URL helpers for web apps.
Building web apps means working with URLs constantly, and a few tasks are fiddlier than they should be. larzurl handles them simply - parsing a URL into its parts, reading and writing query strings, and urljoin() that avoids the double/missing-slash bugs manual string concatenation invites.
larzscript pkg install url
What you get
- Parse a URL into its parts
- parse/build query strings
- Percent-encode/decode
- urljoin() base + path cleanly
Try it
import "url" as url
let u = url.parse("https://example.com/path?a=1&b=two words")
print(u["scheme"], u["host"], u["path"], u["query"]["b"])
print(url.encode("two words"))
print(url.build_query({"a": 1, "b": "x y"}))
print(url.urljoin("https://example.com/api/", "users"))
print(url.urljoin("https://example.com/api/", "/users"))Output
https example.com /path two words two%20words a=1&b=x%20y https://example.com/api/users https://example.com/users
Why it's in the Larz Stack
larzurl is a real Larzscript package (larzscript pkg install url) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.