package eliom

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Eliom_lib.UrlSource

URL manipulation

See <<a_api project="ocsigenserver"| module Ocsigen_lib.Url_base >> .

include module type of Url_base
type t = string
type uri = string
val make_absolute_url : https:bool -> host:string -> port:int -> uri -> t
type path = string list
val remove_dotdot : path -> path
val remove_end_slash : string -> string
val remove_internal_slash : path -> path
val change_empty_list : path -> path
val add_end_slash_if_missing : path -> path
val remove_slash_at_end : path -> path
val remove_slash_at_beginning : path -> path
val is_prefix_skip_end_slash : string list -> string list -> bool
val split_fragment : string -> string * string option
val join_path : path -> string
val norm_path : path -> path

See <<a_api project="js_of_ocaml"| module Js_of_ocaml.Url >> .

include module type of Js_of_ocaml.Url

The first functions are mainly from and to string conversion functions for the different parts of a url.

Sourceval urldecode : string -> string

urldecode s swaps percent encoding characters for their usual representation.

Sourceval urlencode : ?with_plus:bool -> string -> string

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.

Sourcetype http_url = Js_of_ocaml.Url.http_url = {
  1. hu_host : string;
    (*

    The host part of the url.

    *)
  2. hu_port : int;
    (*

    The port for the connection if any.

    *)
  3. hu_path : string list;
    (*

    The path split on '/' characters.

    *)
  4. hu_path_string : string;
    (*

    The original entire path.

    *)
  5. hu_arguments : (string * string) list;
    (*

    Arguments as a field-value association list.

    *)
  6. hu_fragment : string;
    (*

    The fragment part (after the '#' character).

    *)
}

The type for HTTP(s) url.

Sourcetype file_url = Js_of_ocaml.Url.file_url = {
  1. fu_path : string list;
  2. fu_path_string : string;
  3. fu_arguments : (string * string) list;
  4. fu_fragment : string;
}

The type for local file urls.

Sourcetype url = Js_of_ocaml.Url.url =
  1. | Http of http_url
    (*

    Non secure HTTP urls

    *)
  2. | Https of http_url
    (*

    Secure HTTPS urls

    *)
  3. | File of file_url
    (*

    Local files

    *)

The type for urls.

Sourceval default_http_port : int

The default port for Http communications (80).

Sourceval default_https_port : int

The default port for Https communications (443).

Sourceval path_of_path_string : string -> string list

path_of_path_string s splits s on each "/" character.

Sourceval encode_arguments : (string * string) list -> string

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.

Sourceval decode_arguments : string -> (string * string) list

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.

Sourceval url_of_string : string -> url option

url_of_string s parses s and builds a value of type url if s is not a valid url string, it returns None.

Sourceval string_of_url : url -> string

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.

This module can be used to handle the Url associated to the current document.

Sourceval decode : string -> string
Sourceval encode : ?plus:bool -> string -> string
Sourceval make_encoded_parameters : (string * string) list -> string
Sourceval split_path : string -> string list
Sourceval get_ssl : string -> bool option
Sourceval resolve : string -> string
Sourceval add_get_args : string -> (string * string) list -> string
Sourceval string_of_url_path : encode:bool -> string list -> string
Sourceval path_of_url : url -> string list
Sourceval path_of_url_string : string -> string list

Extracts path from a URL string. Works on a best-effort basis for relative URLs

OCaml

Innovation. Community. Security.