LanguageValues and typesStandard typesWeb and network
RelativeUrl
On this page
An address relative to another: ../images/logo.png, ?page=2.
Use it for links inside a document. web.resolve makes a Url of one. For a plain path from the root, use UrlPath.
Shape
One value, held as text in one set form, with no parts: caf%C3%A9.html.
Example
RelativeUrl("../images/logo.png")RelativeUrl(raw) checks the text, and text that isn't one breaks the format rule.
text.parse(raw, as: RelativeUrl) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as https://example.com/, mailto:someone@example.com or a:b.
Good to know
- A scheme is refused, so
https://example.com/is aUrlinstead. ==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string, in a request, a response or json.write:
"../images/logo.png""/docs?page=2#intro""//cdn.example.com/app.js"
Details
Text form, storage, how it is shown, and operations
RelativeUrl is in the group Web and network, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: ../images/logo.png, /docs?page=2#intro and //cdn.example.com/app.js.
How it is stored
It is stored in one column named for the field, of type text. ?sort=name is stored as '?sort=name'.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
../images/logo.png |
../images/logo.png |
/docs?page=2#intro |
/docs?page=2#intro |
//cdn.example.com/app.js |
//cdn.example.com/app.js |
?sort=name |
?sort=name |
#top |
#top |
caf%C3%A9.html |
caf%C3%A9.html |
Operations
web.resolve(base: Url, relative: RelativeUrl) -> Url:relativeresolved againstbaseby RFC 3986 (section 5.2): its.and..segments followed, a path starting/taken from the host, a query or a fragment alone kept with the base's path. AUrlPathis aRelativeUrl, so it resolves too.
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-relative-url.md.Built from Jadpo main at aee2e8f.