@std/net/url.ms#
Import each required symbol with import Name from "@std/net/url.ms".
QueryEntry Type#
One decoded key and value in a URL query string.
type QueryEntry {
key String
value String
}QueryEntry.key#
Decoded query key; duplicate keys retain separate entries in input order.
key StringQueryEntry.value#
Decoded query value; a bare key has an empty value and plus decodes as a space.
value StringUrl Type#
Parsed URL components. A missing port is represented by null.
type Url {
scheme String
host String
path String
fragment String
query String? = null
port Int? = null
omit_host Bool = false
}Url.fragment#
Decoded fragment contents without the leading hash mark.
fragment StringUrl.host#
Lowercased hostname, excluding the port and IPv6 brackets; an IPv6 zone identifier keeps its case. User information is rejected.
host StringUrl.omit_host#
True when the URL was written without //, as in mailto:?subject=hi; format
then omits the empty authority, so the text round-trips.
omit_host Bool = falseUrl.path#
Escaped path text, retaining escaped separators; format validates its percent escapes and UTF-8.
path StringUrl.port#
Explicit numeric port in 0..65535, or null when the input has no port.
port Int? = nullUrl.query#
Encoded query contents without the leading question mark, or null when the URL
has no query; http://a/b? has an empty one. parse_query decodes individual
entries.
query String? = nullUrl.scheme#
URL scheme, lowercased during parsing; native parse rejects missing schemes and opaque URLs.
scheme StringUrl.format#
Formats URL components as an absolute hierarchical URL. Missing or malformed schemes and hostless relative paths return EINVAL, as do other invalid components.
fn format() Result[String, Error]Url.resolve#
Resolves a relative reference against this base URL.
fn resolve(reference String) Result[Url, Error]Url.to_json#
Writes the formatted URL as a JSON string; components format rejects fault.
fn to_json() JsonValuedecode_component Function#
Decodes one percent-encoded URL component. + is not treated as a space.
fn decode_component(text String) Result[String, Error] { ... }encode_component Function#
Percent-encodes one URL component using UTF-8 bytes.
fn encode_component(text String) String { ... }format_query Function#
Encodes query entries as a query string.
fn format_query(entries List[QueryEntry]) String { ... }parse Function#
Parses an absolute URL into its components.
fn parse(text String) Result[Url, Error] { ... }parse_query Function#
Parses a query string, preserving duplicate keys and their input order.
fn parse_query(text String, max_entries Int? = null) Result[List[QueryEntry], Error] { ... }