package js_of_ocaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0ea48e2aa8904ec562f225fa093ff674b54e0e7514dae8627b8fd8f77210383d
sha512=c6df6875631d0f7e647e31dff26da696869e83391a1040461445d2ed895985f83f60acdd045b773f05c955e3d61cee10491d947df6071637e1bb65cd373d6285
doc/js_of_ocaml/Js_of_ocaml/Url/index.html
Module Js_of_ocaml.UrlSource
This module provides functions for tampering with Url. It's main goal is to allow one to stay in the Ocaml realm without wandering into the Dom_html.window##.location object.
The first functions are mainly from and to string conversion functions for the different parts of a url.
urldecode s swaps percent encoding characters for their usual representation.
urlencode ?with_plus s replace characters for their percent encoding representation. Note that the '/' (slash) character is escaped as well. If with_plus is true (default) then '+''s are escaped as "%2B". If not, '+''s are left as is.
type http_url = {hu_host : string;(*The host part of the url.
*)hu_port : int;(*The port for the connection if any.
*)hu_path : string list;(*The path split on
*)'/'characters.hu_path_string : string;(*The original entire path.
*)hu_arguments : (string * string) list;(*Arguments as a field-value association list.
*)hu_fragment : string;(*The fragment part (after the
*)'#'character).
}The type for HTTP(s) url.
type file_url = {fu_path : string list;fu_path_string : string;fu_arguments : (string * string) list;fu_fragment : string;
}The type for local file urls.
The type for urls.
The default port for Http communications (80).
The default port for Https communications (443).
path_of_path_string s splits s on each "/" character.
encode_arguments a expects a list of pair of values of the form (name,value) were name is the name of an argument and value it's associated value.
decode_arguments s parses s returning the sliced-diced association list. s should be only the arguments part (after the '?') not the whole url.
The following part allow one to handle Url object in a much higher level than what a string provides.
url_of_string s parses s and builds a value of type url if s is not a valid url string, it returns None.
string_of_url u returns a valid string representation of u. Note that * string_of_url ((fun Some u -> u) (url_of_string s)) is NOT necessarily * equal to s. However url_of_string (string_of_url u) = u.