@std/url.ms#
Import each required symbol with import Name from "@std/url.ms".
QueryEntry Record#
One decoded key and value in a URL query string.
type QueryEntry:
key: String
value: StringQueryEntry.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 Record#
Parsed URL components. A missing port is represented by none.
type Url:
scheme: String
host: String
port: Optional[Int]
path: String
query: String
fragment: StringUrl.fragment#
Decoded fragment contents without the leading hash mark.
fragment: StringUrl.host#
Lowercased hostname, excluding the port and IPv6 brackets; user information is rejected.
host: StringUrl.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 none when the input has no port.
port: Optional[Int]Url.query#
Encoded query contents without the leading question mark; parse_query decodes individual entries.
query: StringUrl.scheme#
URL scheme, lowercased during parsing; native parse rejects missing schemes and opaque URLs.
scheme: StringUrlError Alternative#
Errors returned for malformed URL text, components, or query limits.
type UrlError:
case InvalidInput
case InvalidData
case LimitExceededimpl Error for UrlError:
fn message() -> String:UrlError.InvalidData#
URL text, escaped bytes, port syntax or a relative reference is invalid or unsupported.
case InvalidDataUrlError.InvalidInput#
Constructed URL components or a supplied query-entry budget are invalid.
case InvalidInputUrlError.LimitExceeded#
The decoded query has more entries than its supplied budget permits.
case LimitExceededUrlError.Error.message#
Returns a URL-prefixed diagnostic without echoing addresses, query values or credentials.
fn message() -> String:decode_component Function#
Decodes one percent-encoded URL component. + is not treated as a space.
fn decode_component(text: String) -> Result[String, UrlError]:encode_component Function#
Percent-encodes one URL component using UTF-8 bytes.
fn encode_component(text: String) -> String:format Function#
Formats URL components as an absolute or relative URL.
fn format(value: Url) -> Result[String, UrlError]: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, UrlError]:parse_query Function#
Parses a query string, preserving duplicate keys and their input order.
fn parse_query(text: String, max_entries: Optional[Int] = none) -> Result[List[QueryEntry], UrlError]:resolve Function#
Resolves a relative reference against a base URL.
fn resolve(base: Url, reference: String) -> Result[Url, UrlError]: