Manuscript Documentation
v2026.12.0

@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.

Manuscript
type QueryEntry {
    key String
    value String
}

QueryEntry.key#

Decoded query key; duplicate keys retain separate entries in input order.

Manuscript
key String

QueryEntry.value#

Decoded query value; a bare key has an empty value and plus decodes as a space.

Manuscript
value String

Url Type#

Parsed URL components. A missing port is represented by null.

Manuscript
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.

Manuscript
fragment String

Url.host#

Lowercased hostname, excluding the port and IPv6 brackets; an IPv6 zone identifier keeps its case. User information is rejected.

Manuscript
host String

Url.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.

Manuscript
omit_host Bool = false

Url.path#

Escaped path text, retaining escaped separators; format validates its percent escapes and UTF-8.

Manuscript
path String

Url.port#

Explicit numeric port in 0..65535, or null when the input has no port.

Manuscript
port Int? = null

Url.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.

Manuscript
query String? = null

Url.scheme#

URL scheme, lowercased during parsing; native parse rejects missing schemes and opaque URLs.

Manuscript
scheme String

Url.format#

Formats URL components as an absolute hierarchical URL. Missing or malformed schemes and hostless relative paths return EINVAL, as do other invalid components.

Manuscript
fn format() Result[String, Error]

Url.resolve#

Resolves a relative reference against this base URL.

Manuscript
fn resolve(reference String) Result[Url, Error]

Url.to_json#

Writes the formatted URL as a JSON string; components format rejects fault.

Manuscript
fn to_json() JsonValue

decode_component Function#

Decodes one percent-encoded URL component. + is not treated as a space.

Manuscript
fn decode_component(text String) Result[String, Error] { ... }

encode_component Function#

Percent-encodes one URL component using UTF-8 bytes.

Manuscript
fn encode_component(text String) String { ... }

format_query Function#

Encodes query entries as a query string.

Manuscript
fn format_query(entries List[QueryEntry]) String { ... }

parse Function#

Parses an absolute URL into its components.

Manuscript
fn parse(text String) Result[Url, Error] { ... }

parse_query Function#

Parses a query string, preserving duplicate keys and their input order.

Manuscript
fn parse_query(text String, max_entries Int? = null) Result[List[QueryEntry], Error] { ... }