File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -438,6 +438,12 @@ module Path = struct
438438 ) " " buf p;
439439 Pct. cast_encoded (Buffer. contents buf)
440440
441+ let decoded_of_path p =
442+ let len = List. fold_left (fun c tok -> String. length tok + c) 0 p in
443+ let buf = Buffer. create len in
444+ iter_concat (fun buf s -> Buffer. add_string buf s) " " buf p;
445+ Pct. cast_decoded (Buffer. contents buf)
446+
441447 (* Subroutine for resolve <http://tools.ietf.org/html/rfc3986#section-5.2.3> *)
442448 let merge bhost bpath relpath =
443449 match bhost, List. rev bpath with
448454
449455let path_of_encoded = Path. path_of_encoded
450456let encoded_of_path ?scheme ~component = Path. encoded_of_path ?scheme ~component
457+ let decoded_of_path = Path. decoded_of_path
451458
452459(* Query string handling, to and from an assoc list of key/values *)
453460module Query = struct
@@ -754,6 +761,8 @@ let with_path uri path =
754761 | None , _ | Some _ , "/" ::_ | Some _ , [] -> { uri with path= path }
755762 | Some _ , _ -> { uri with path= " /" ::path }
756763
764+ let path_unencoded uri = Pct. uncast_decoded (decoded_of_path uri.path)
765+
757766let fragment uri = get_decoded_opt uri.fragment
758767let with_fragment uri =
759768 function
Original file line number Diff line number Diff line change @@ -211,6 +211,9 @@ val path : ?pct_encoder:pct_encoder -> t -> string
211211(* * Get the encoded path and query components of a URI *)
212212val path_and_query : t -> string
213213
214+ (* * Get the unencoded path component of a URI *)
215+ val path_unencoded : t -> string
216+
214217(* * Replace the path URI with the supplied encoded path.
215218 If a host is present in the supplied URI, the path is made absolute but not
216219 resolved. If the path is empty, the path component is removed.
You can’t perform that action at this time.
0 commit comments