Skip to content

Commit

Permalink
Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jonludlam committed Aug 21, 2024
1 parent 10fbf04 commit 69320ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/html/link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ module Path = struct

let remap config f =
let l = String.concat "/" f in
match
List.find_opt
(fun (prefix, _replacement) -> Astring.String.is_prefix ~affix:prefix l)
(Config.remap config)
with
| None -> None
| Some (prefix, replacement) ->
let len = String.length prefix in
let l = String.sub l len (String.length l - len) in
Some (replacement ^ l)
try
let prefix, replacement =
List.find
(fun (prefix, _replacement) ->
Astring.String.is_prefix ~affix:prefix l)
(Config.remap config)
in
let len = String.length prefix in
let l = String.sub l len (String.length l - len) in
Some (replacement ^ l)
with Not_found -> None

let get_dir_and_file ~config url =
let l = Url.Path.to_list url in
Expand Down
2 changes: 1 addition & 1 deletion src/odoc/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ module Odoc_html_args = struct
let convert_remap =
let parse inp =
match Astring.String.cut ~sep:":" inp with
| Some (orig, mapped) -> Ok (orig, mapped)
| Some (orig, mapped) -> Result.Ok (orig, mapped)
| _ -> Error (`Msg "Map must be of the form '<orig>:https://...'")
and print fmt (orig, mapped) = Format.fprintf fmt "%s:%s" orig mapped in
Arg.conv (parse, print)
Expand Down

0 comments on commit 69320ef

Please sign in to comment.