this repo has no description

Remapping favours the longest prefix

+23 -11
+16 -11
src/html/link.ml
··· 13 13 14 14 let remap config f = 15 15 let l = String.concat "/" f in 16 - try 17 - let prefix, replacement = 18 - List.find 19 - (fun (prefix, _replacement) -> 20 - Astring.String.is_prefix ~affix:prefix l) 21 - (Config.remap config) 22 - in 23 - let len = String.length prefix in 24 - let l = String.sub l len (String.length l - len) in 25 - Some (replacement ^ l) 26 - with Not_found -> None 16 + let remaps = 17 + List.filter 18 + (fun (prefix, _replacement) -> Astring.String.is_prefix ~affix:prefix l) 19 + (Config.remap config) 20 + in 21 + let remaps = 22 + List.sort 23 + (fun (a, _) (b, _) -> compare (String.length b) (String.length a)) 24 + remaps 25 + in 26 + match remaps with 27 + | [] -> None 28 + | (prefix, replacement) :: _ -> 29 + let len = String.length prefix in 30 + let l = String.sub l len (String.length l - len) in 31 + Some (replacement ^ l) 27 32 28 33 let get_dir_and_file ~config url = 29 34 let l = Url.Path.to_list url in
+7
test/integration/remap.t/run.t
··· 18 18 19 19 $ odoc html-generate -o _html3 _odoc/prefix/otherpkg/otherlib.odocl -R prefix/otherpkg/:https://mysite.org/p/otherpkg/1.2.3/ 20 20 21 + The order shouldn't matter, the longest prefix ought to win 22 + $ odoc html-generate -o _html3 --indent _odoc/prefix/mypkg/test.odocl -R prefix/:https://mysite.org/foo/ -R prefix/otherpkg/:https://mysite.org/bar/ 23 + $ odoc html-generate -o _html4 --indent _odoc/prefix/mypkg/test.odocl -R prefix/otherpkg/:https://mysite.org/bar/ -R prefix/:https://mysite.org/foo/ 24 + 25 + $ grep Otherlib/index.html _html3/prefix/mypkg/Test/index.html _html4/prefix/mypkg/Test/index.html 26 + _html3/prefix/mypkg/Test/index.html: <a href="https://mysite.org/bar/Otherlib/index.html#type-t">Otherlib.t 27 + _html4/prefix/mypkg/Test/index.html: <a href="https://mysite.org/bar/Otherlib/index.html#type-t">Otherlib.t