Module Http.Path
Paths.
val drop_prefix : path -> path -> path
drop_prefix pre p
drops prefixpre
fromp
. Ifpre
is not a prefix ofp
this isp
.TODO talk about final "".
val undot_and_compress : path -> path
undot_and_compress p
removes"."
and".."
according to the RFC3986 algorithm and suppresses non final empty""
segments.
val to_undotted_filepath : path -> (string, string) Stdlib.result
to_undotted_filepath p
is an absolute filepath forundot_and_compress p
. It returns "/". Errors if any of the path segments contains a stray slash or backslash. The result always uses/
as a directory separator regardless of the platform.
val prefix_filepath : string -> string -> string
prefix_filepath p0 p1
prefixesp1
byp0
avoiding producing empty segs.
Converting
val encode : path -> string
encode p
encodes anabsolute-path
forp
as follows:- In each segment percent-encode any byte that is not
unreserved
,sub-delims
,':'
or'@'
to produce a valid URIsegment
. - Prepends each segment with a
'/'
. - Concatenate the result.
The empty list is special cased and yields
""
.path_to_undotted_filepath
to convert paths to file paths.Here are a few examples:
decode [] = ""
decode [""] = "/"
decode [""; ""] = "//"
decode ["a";"b";"c"] = "/a/b/c"
decode ["a";"b";"";"c";] = "/a/b//c"
decode ["a";"b";"c";""] = "/a/b/c/"
decode ["a";"b";"c";" "] = "/a/b/c/%20"
decode ["a";"b";"c";"";""] = "/a/b/c//"
decode ["a"; "b/"; "c"] = "/a/b%2F/c"
decode ["r\xC3\xC9volte"] = "/r%C3%C9volte"
decode ["a"; "not%20"; "b"] = "/a/not%2520/b"
- In each segment percent-encode any byte that is not
val decode : string -> (path, string) Stdlib.result
decode s
decodes anabsolute-path
to its percent-decoded list of segments. By definition ofabsolute-path
the list of segments is never empty.Here are a few examples:
decode "/" = Some [""]
decode "//" = Some ["",""]
decode "/a/b/c" = Some ["a";"b";"c"]
decode "/a/b//c" = Some ["a";"b";"";"c"]
decode "/a/b/c/" = Some ["a";"b";"c";""]
decode "/a/b/c/%20" = Some ["a";"b";"c";" "]
decode "/a/b//c//" = Some ["a";"b";"";"c";"";""]
decode "/a/b%2F/c" = Some ["a"; "b/"; "c"]
decode "/r%C3%C9volte" = Some ["r\xC3\xC9volte"]
decode "/a/not%2520/b" = Some ["a"; "not%20"; "b"]
decode "" = Error _
decode "a/b/c" = Error _
val pp : Stdlib.Format.formatter -> path -> unit
pp
is an unspecified formatter for paths.