std::net::urlURL parsing.
Parse URLs into their components (scheme, host, port, path, query, fragment) and reconstruct or join them.
import std::net::url;
fn main() {
let u = url.parse("https://example.com:8080/path?key=val#frag");
println(u.host());
println(u.port());
u.free();
}
parseParse a URL string.
Panics if the string is not a valid URL.
let u = url.parse("https://example.com/api/v1");
encodePercent-encode a string (RFC 3986 unreserved characters are left unchanged).
import std::net::url;
let encoded = url.encode("hello world"); // "hello%20world"
decodeDecode a percent-encoded string.
Returns an empty string on decode error.
import std::net::url;
let decoded = url.decode("hello%20world"); // "hello world"
encode_queryBuild a percent-encoded query string from a newline-separated list of
key=value pairs.
Each line should be key=value. Lines without = are skipped. Pairs are
joined with &.
import std::net::url;
let qs = url.encode_query("name=hello world\npage=1");
// "name=hello%20world&page=1"
UrlA parsed URL.
Created by url.parse(s). Must be freed with free() when
no longer needed to avoid leaking memory.
UrlMethodsMethods available on a parsed Url.