Module url/index
url/index
URL parsing and formatting per RFC 3986 (simplified).
Types
Url
object
Url
Parsed URL with scheme, host, port, path, query, and fragment components.
Fields
| Name | Type | Description |
|---|---|---|
_scheme | String | |
_host | Option(String) | |
_port | Option(u16) | |
_path | String | |
_query | Option(String) | |
_fragment | Option(String) | |
_userinfo | Option(String) |
Trait Implementations
impl(Url, ...)
parse : (Url) fn(s : str, using(exn : Exception)) -> Urlhost : (Url) fn(self : Url) -> Option(String)query : (Url) fn(self : Url) -> Option(String)fragment : (Url) fn(self : Url) -> Option(String)userinfo : (Url) fn(self : Url) -> Option(String)host_port : (Url) fn(self : Url) -> Option(String)impl(Url, ToString(...))
to_string : (self -> {
result := `${self._scheme}:`;
match(self._host,
.Some(h) => {
result = result.concat(`//`);
match(self._userinfo,
.Some(ui) => {
result = result.concat(ui).concat(`@`);
},
.None => ()
);
result = result.concat(h);
match(self._port,
.Some(p) => {
result = result.concat(`:${p}`);
},
.None => ()
);
},
.None => ()
);
result = result.concat(self._path);
match(self._query,
.Some(q) => {
result = result.concat(`?`).concat(q);
},
.None => ()
);
match(self._fragment,
.Some(f) => {
result = result.concat(`#`).concat(f);
},
.None => ()
);
result
})
UrlError
enum
UrlError
Errors that can occur during URL parsing.
Variants
| Variant | Fields | Description |
|---|---|---|
EmptyInput | ||
MissingScheme | ||
InvalidPort | ||
InvalidCharacter | pos: usize | |
Other | msg: String |
Trait Implementations
impl(UrlError, ToString(...))
to_string : (self ->
match(self,
.EmptyInput => `URL error: empty input`,
.MissingScheme => `URL error: missing scheme`,
.InvalidPort => `URL error: invalid port`,
.InvalidCharacter(pos) => `URL error: invalid character at position ${pos}`,
.Other(msg) => `URL error: ${msg}`
)
)