package opam-core

  1. Overview
  2. Docs

URL parsing and printing, with support for our different backends

type version_control = [
  1. | `git
  2. | `darcs
  3. | `hg
]
type backend = [
  1. | `http
  2. | `rsync
  3. | version_control
]
val string_of_backend : backend -> string
exception Parse_error of string
val backend_of_string : string -> [> backend ]

Tolerates lots of backward compatibility names;

type t = {
  1. transport : string;
    (*

    the part just before '://'

    *)
  2. path : string;
    (*

    the part after '://'

    *)
  3. hash : string option;
    (*

    the optional branch/ref specification, at the end after a '#'

    *)
  4. backend : backend;
    (*

    the backend that opam should use to handle this url

    *)
}
val parse : ?backend:backend -> ?handle_suffix:bool -> ?from_file:bool -> string -> t

Same as of_string, but allows enforcing the expected backend, and may otherwise guess version control from the suffix by default (for e.g. https://foo/bar.git). (this should be disabled when parsing from files). Note that handle_suffix also handles user-name in ssh addresses (e.g. "ssh://git@github.com/..."). If from_file is set to false, it resolves rsync/file relative path.

val parse_opt : ?quiet:bool -> ?backend:backend -> ?handle_suffix:bool -> ?from_file:bool -> string -> t option

Same as parse, but catch Parse_error. In this case, display a warning if quiet is not set to true.

include OpamStd.ABSTRACT with type t := t
val compare : t -> t -> int
val equal : t -> t -> bool
val of_string : string -> t
val to_string : t -> string
val to_json : t OpamJson.encoder
val of_json : t OpamJson.decoder
module Set : OpamStd.SET with type elt = t
module Map : OpamStd.MAP with type key = t
val to_string_w_subpath : OpamFilename.SubPath.t option -> t -> string
val empty : t

Dummy filler url

val base_url : t -> string

Returns the url string without the VC part (i.e. "git+foo://bar" returns "foo://bar")

val basename : t -> string

The last part of the url path, e.g. "http://foo/bar/this" or "http://that.here/"

val root : t -> t

Returns the url with all path components but the first one (the hostname) dropped, e.g. "http://some.host/some/path" becomes "http://some.host"

val has_trailing_slash : t -> bool
val local_dir : t -> OpamFilename.Dir.t option

Check if the URL matches an existing local directory, and return it

val local_file : t -> OpamFilename.t option

Check if the URL matches an existing local file, and return it

val guess_version_control : string -> [> version_control ] option

If the given url-string has no 'transport://' specification and corresponds to an existing local path, check for version-control clues at that path

val map_file_url : (string -> string) -> t -> t

map_file_url f url applies f to the path portion of url if transport is "file".

module Op : sig ... end
OCaml

Innovation. Community. Security.