Skip to content

url

URLs without a dependency: percent-encoding, query strings, a parser and reference resolution.

percent_encode / percent_decode handle one component, parse_query / build_query turn a query string into pairs and back, join_path glues path pieces, and Url parses a whole URL (RFC 3986) and resolves relative references against it. Malformed input is an error, never a silent fix.

Cargo feature url (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features url

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["url"] }

Import path: helpers4::url.

ItemWhat it does
build_queryBuilds a query string (a=1&b=two) from key-value pairs, percent-encoding both sides.
join_pathJoins two pieces of a URL or path with exactly one / between them.
parse_queryParses a query string (a=1&b=two) into its key-value pairs, decoded, in order.
UrlA parsed URL: scheme://userinfo@host:port/path?query#fragment.
percent_decodeDecodes the %XX escapes of input.
percent_encodePercent-encodes input for use as one URL component: a path segment, a query key or value.

Documented on the page of the helper that returns them.

TypeReturned by
PercentDecodeErrorparse_query, percent_decode
UrlErrorUrl