Library
Module
Module type
Parameter
Class
Class type
URIs and URI parameters.
Uri.t
values are URL objects but we tweak the API to return data according to RFC 3986 terminology: we don't return separators like ':'
, '?'
and '#'
in the data and we use host
for what is hostname
in the URL API. Also the data we return is URL (percent) decoded).
The type for URL
objects.
v ?base s
is an URI from s
relative to base
(if specified). Raises in in case of error, use of_jstr
if you need to deal with user input.
val port : t -> int option
port u
is the port of u
.
val with_uri :
?scheme:Jstr.t ->
?host:Jstr.t ->
?port:int option ->
?path:Jstr.t ->
?query:Jstr.t ->
?fragment:Jstr.t ->
t ->
(t, Jv.Error.t) result
with_uri u
is u
with the specified components updated. The given parameters are URL (percent) encoded by the function.
module Params : sig ... end
URI fragment or query parameters.
val encode : Jstr.t -> (Jstr.t, Jv.Error.t) result
encode s
URL encodes s
by percent-encoding an UTF-8 representation of s
. See encodeURI.
val decode : Jstr.t -> (Jstr.t, Jv.Error.t) result
decode s
URL decodes s
by percent-decoding an UTF-8 representation of s
. See decodeURI.
val encode_component : Jstr.t -> (Jstr.t, Jv.Error.t) result
encode s
URL encodes s
by percent-encoding an UTF-8 representation of s
. See encodeURIComponent.
val decode_component : Jstr.t -> (Jstr.t, Jv.Error.t) result
decode s
URL decodes s
by precent-decoding an UTF-8 representation of s
. See decodeURIComponent.
val of_jstr : ?base:Jstr.t -> Jstr.t -> (t, Jv.Error.t) result
of_jstr ~base s
is an URL from s
relative to base
(if specified). Note that if s
is relative and base
is unspecified the function errors.