This module implements URI parsing as specified by RFC 3986.
Url = distinct string
Uri = object scheme*, username*, password*: string hostname*, port*, path*, query*, anchor*: string opaque*: bool
proc `$`(url: Url): string {.deprecated, raises: [], tags: [].}
Uri
instead. proc `/`(a, b: Url): Url {.deprecated, raises: [], tags: [].}
Joins two URLs together, separating them with / if needed.
Deprecated since 0.9.6: Use Uri
instead.
proc add(url: var Url; a: Url) {.deprecated, raises: [], tags: [].}
Appends url to url.
Deprecated since 0.9.6: Use Uri
instead.
proc initUri(): Uri {.raises: [], tags: [].}
proc parseUri(uri: string; result: var Uri) {.raises: [ValueError], tags: [].}
proc parseUri(uri: string): Uri {.raises: [ValueError], tags: [].}
proc combine(base: Uri; reference: Uri): Uri {.raises: [], tags: [].}
Combines a base URI with a reference URI.
This uses the algorithm specified in section 5.2.2 of RFC 3986.
This means that the slashes inside the base URI's path as well as reference URI's path affect the resulting URI.
For building URIs you may wish to use `/` instead.
Examples:
let foo = combine(parseUri("http://example.com/foo/bar"), parseUri("/baz")) assert foo.path == "/baz" let bar = combine(parseUri("http://example.com/foo/bar"), parseUri("baz")) assert bar.path == "/foo/baz" let bar = combine(parseUri("http://example.com/foo/bar/"), parseUri("baz")) assert bar.path == "/foo/bar/baz"
proc combine(uris: varargs[Uri]): Uri {.raises: [], tags: [].}
proc isAbsolute(uri: Uri): bool {.raises: [], tags: [].}
proc `/`(x: Uri; path: string): Uri {.raises: [], tags: [].}
Concatenates the path specified to the specified URI's path.
Contrary to the combine
procedure you do not have to worry about the slashes at the beginning and end of the path and URI's path respectively.
Examples:
let foo = parseUri("http://example.com/foo/bar") / "/baz" assert foo.path == "/foo/bar/baz" let bar = parseUri("http://example.com/foo/bar") / "baz" assert bar.path == "/foo/bar/baz" let bar = parseUri("http://example.com/foo/bar/") / "baz" assert bar.path == "/foo/bar/baz"
proc `$`(u: Uri): string {.raises: [], tags: [].}
© 2006–2017 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/uri.html