std::url
A utility module for working with URLs.
Classes
-
URL() -> URL -
Returns a new
URLinstance.
URL instances have the following public fields:
class URL { pub var scheme: str?; pub var username: str?; pub var password: str?; pub var host: str?; pub var port: str?; pub var path: str?; pub var query: str?; pub var fragment: str?; }
URL instances have the following public methods:
-
:port_number() -> i64 -
Returns the port number as an integer.
Functions
-
parse_query(input: str) -> map[str, vec[str]]|err -
Parses a URL-encoded query string.
-
Returns a
mapmappingstrkeys to vectors ofstrvalues. -
Returns an
errif the query string is invalidly-encoded.
The input can be a full URL — everything up to the first
?will be ignored. -
Returns a
-
parse_url(input: str) -> URL|err -
Parses a URL into its component parts. Returns an
errif the input is not a valid URL.This function can parse both absolute URLs and site-relative URLs beginning with a
/. -
url_decode(input: str) -> str|err -
Returns a new string containing the URL-decoded content of the input string. Returns an error if the input is invalidly-encoded.
-
url_encode(input: str) -> str -
Returns a new string containing the URL-encoded content of the input string.