From 1dcf38af93ae28efecd6fb17bb44a04611e322ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dimino?= Date: Mon, 13 Mar 2017 08:53:41 +0000 Subject: [PATCH] Fix Path.extract_build* functions when applied on the build_dir itself This should fix #20 --- src/path.ml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/path.ml b/src/path.ml index c5030677..cbdd4240 100644 --- a/src/path.ml +++ b/src/path.ml @@ -309,24 +309,28 @@ let is_in_build_dir t = let extract_build_context t = if is_local t && String.is_prefix t ~prefix:build_prefix then let i = String.length build_prefix in - match String.index_from t i '/' with - | exception _ -> None - | j -> - Some - (String.sub t ~pos:i ~len:(j - i), - String.sub t ~pos:(j + 1) ~len:(String.length t - j - 1)) + let j = + match String.index_from t i '/' with + | exception _ -> String.length t + | j -> j + in + Some + (String.sub t ~pos:i ~len:(j - i), + String.sub t ~pos:(j + 1) ~len:(String.length t - j - 1)) else None let extract_build_context_dir t = if is_local t && String.is_prefix t ~prefix:build_prefix then let i = String.length build_prefix in - match String.index_from t i '/' with - | exception _ -> None - | j -> - Some - (String.sub t ~pos:0 ~len:j, - String.sub t ~pos:(j + 1) ~len:(String.length t - j - 1)) + let j = + match String.index_from t i '/' with + | exception _ -> String.length t + | j -> j + in + Some + (String.sub t ~pos:0 ~len:j, + String.sub t ~pos:(j + 1) ~len:(String.length t - j - 1)) else None