Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/baselib/ocsigen_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,20 @@ module Url = struct

let split_path = Neturl.split_path

let prefix_and_path_of_t url =
let (https, host, port, _, path, _, _) = parse url in
let https_str = match https with
| None -> ""
| Some x -> if x then "https://" else "http://"
in
let host_str = match host with
| None -> ""
| Some x -> x
in
let port_str = match port with
| None -> ""
| Some x -> string_of_int x
in
(https_str ^ host_str ^ ":" ^ port_str, path)

end
9 changes: 9 additions & 0 deletions src/baselib/ocsigen_lib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@ module Url : sig
(** alias of (Ocamlnet) [Neturl.split_path] *)
val split_path : string -> string list

(** [prefix_and_path_of_t url] splits [url] in a couple [(prefix, path)] where
[prefix] is ["http(s)://host:port"] and [path] is the path as [string list]
Example: [prefix_and_path_of_t "http://ocsigen.org:80/tuto/manual"]
returns [("http://ocsigen.org:80", ["tuto", "manual"])].
*)
val prefix_and_path_of_t :
string ->
string * string list
end