std/text/url
std/url — URL percent-encoding + scheme/host/path decomposition, in
pure Axle.urlEncode follows the RFC 3986 unreserved set: A-Za-z0-9-._~
pass through, everything else becomes %HH (uppercase hex).urlEncodeForm additionally maps space to +
(application/x-www-form-urlencoded). Decoding validates the rebuilt
bytes as UTF-8 and raises ParseException on a truncated escape, a
non-hex digit, or a non-UTF-8 result.
Decomposition is best-effort — a missing component yields "" (or -1
for the port). It mirrors the reference splitting: the scheme is the
text before the first : when that prefix is scheme-shaped; the
authority is what follows // up to the next / ? #; the host
drops any user@ prefix and :port suffix.
The structural ASCII bytes are named in each function (module-levelconst is unsupported) so the branches read in characters.
Free functions
| Type | Method and description |
|---|---|
| __isUnreserved(byte : i32) : bool RFC 3986 unreserved byte: A-Za-z0-9 plus - _ . ~. |
| __isSchemeByte(byte : i32) : bool Byte allowed in a URL scheme: A-Za-z0-9 plus + - .. |
| __substr(s : string, start : i64, end : i64) : string Materialise the bytes of [start, end) as an owned string. |
| __pctEncode(s : string, plusForSpace : bool) : string Percent-encode s. Unreserved bytes pass through; whenplusForSpace is set a space becomes +; every other byte becomes%HH with uppercase hex. |
| __pctDecode(s : string, plusIsSpace : bool) : string Percent-decode s. %HH becomes the byte; when plusIsSpace isset + becomes a space; other bytes pass through. RaisesParseException on a truncated escape, a non-hex digit, or anon-UTF-8 result. |
| urlEncode(s : string) : string Percent-encode s per RFC 3986: the unreserved set A-Za-z0-9-._~passes through, every other byte becomes %HH with uppercase hex. |
| urlDecode(s : string) : string Inverse of [urlEncode]. Raises ParseException on a truncatedescape, a non-hex digit, or a non-UTF-8 result. |
| urlEncodeForm(s : string) : string Like [urlEncode] but in application/x-www-form-urlencoded form:a space becomes + instead of %20. |
| urlDecodeForm(s : string) : string Inverse of [urlEncodeForm]: + decodes back to a space, %HH toits byte. Raises ParseException on a malformed escape or non-UTF-8result. |
| __schemeColon(url : string, srcLen : i64) : i64 Index of the : ending a scheme-shaped prefix, or -1 when the URLhas no scheme (empty prefix, or a non-scheme byte before the first :). |
| __afterScheme(url : string, srcLen : i64) : i64 Byte offset just after the scheme (0 when there is none). |
| __hasAuthority(url : string, srcLen : i64, from : i64) : bool true when an authority (//...) begins at from. |
| __authorityEnd(url : string, srcLen : i64, authStart : i64) : i64 End of the authority region that starts at authStart: the next/, ?, or #, or the URL end. |
| __parseI32OrNeg(s : string, start : i64, end : i64) : i64 Parse [start, end) as a decimal i32 (optional leading sign), or -1when empty, non-numeric, or out of the i32 range — matching the native port parse with its -1 fallback. |
| urlScheme(url : string) : string Scheme, e.g. "https" (or "" when absent). |
| urlHost(url : string) : string Host, e.g. "example.com" — userinfo and port stripped (or "" whenthere is no authority). |
| urlPort(url : string) : i32 Port number, or -1 when absent / unparseable. |
| urlPath(url : string) : string Path, e.g. "/api/v1" (or "" when absent). |
| urlQuery(url : string) : string Query string between ? and # (or end), e.g. "k=v&x=y". |
| urlFragment(url : string) : string Fragment after #, e.g. "section" (or "" when absent). |
Method detail
#__isUnreserved
RFC 3986 unreserved byte: A-Za-z0-9 plus - _ . ~.
byte candidate byte (ASCII code point) to classify#__isSchemeByte
Byte allowed in a URL scheme: A-Za-z0-9 plus + - ..
byte candidate byte (ASCII code point) to classify#__substr
Materialise the bytes of [start, end) as an owned string.
s source stringstart inclusive start byte offset into s, 0-basedend exclusive end byte offset into s#__pctEncode
Percent-encode s. Unreserved bytes pass through; whenplusForSpace is set a space becomes +; every other byte becomes%HH with uppercase hex.
s text whose raw bytes are percent-encodedplusForSpace encode a space as + instead of %20#__pctDecode
Percent-decode s. %HH becomes the byte; when plusIsSpace is
set + becomes a space; other bytes pass through. RaisesParseException on a truncated escape, a non-hex digit, or a
non-UTF-8 result.
s percent-encoded text to decodeplusIsSpace decode + back to a space#urlEncode
Percent-encode s per RFC 3986: the unreserved set A-Za-z0-9-._~
passes through, every other byte becomes %HH with uppercase hex.
s text to percent-encode#urlDecode
Inverse of [urlEncode]. Raises ParseException on a truncated
escape, a non-hex digit, or a non-UTF-8 result.
s percent-encoded text to decode#urlEncodeForm
Like [urlEncode] but in application/x-www-form-urlencoded form:
a space becomes + instead of %20.
s text to form-encode#urlDecodeForm
Inverse of [urlEncodeForm]: + decodes back to a space, %HH to
its byte. Raises ParseException on a malformed escape or non-UTF-8
result.
s form-encoded text to decode#__schemeColon
Index of the : ending a scheme-shaped prefix, or -1 when the URL
has no scheme (empty prefix, or a non-scheme byte before the first:).
url URL text to inspectsrcLen byte length of url#__afterScheme
Byte offset just after the scheme (0 when there is none).
url URL text to inspectsrcLen byte length of url#__parseI32OrNeg
Parse [start, end) as a decimal i32 (optional leading sign), or -1
when empty, non-numeric, or out of the i32 range — matching the
native port parse with its -1 fallback.
s source stringstart inclusive start byte offset of the decimal digitsend exclusive end byte offset of the decimal digits#urlScheme
Scheme, e.g. "https" (or "" when absent).
url URL to decompose#urlHost
Host, e.g. "example.com" — userinfo and port stripped (or "" when
there is no authority).
url URL to decompose#urlPort
Port number, or -1 when absent / unparseable.
url URL to decompose#urlPath
Path, e.g. "/api/v1" (or "" when absent).
url URL to decompose#urlQuery
Query string between ? and # (or end), e.g. "k=v&x=y".
url URL to decompose#urlFragment
Fragment after #, e.g. "section" (or "" when absent).
url URL to decompose