Fix off by 1 in Path.is_descendant
This commit is contained in:
parent
b6851d7cd7
commit
3a8e4cf54d
|
@ -206,7 +206,7 @@ module Local = struct
|
|||
let of_len = String.length of_ in
|
||||
let t_len = String.length t in
|
||||
(t_len = of_len && t = of_) ||
|
||||
(t_len >= of_len && t.[of_len] = '/' && String.is_prefix t ~prefix:of_)
|
||||
(t_len > of_len && t.[of_len] = '/' && String.is_prefix t ~prefix:of_)
|
||||
|
||||
let reach t ~from =
|
||||
let rec loop t from =
|
||||
|
|
|
@ -37,17 +37,17 @@ Path.(is_descendant (r "foo/") ~of_:(r "foo"))
|
|||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "bar"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "index out of bounds".
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo") ~of_:(r "bar/"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "index out of bounds".
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "foo/") ~of_:(r "bar"))
|
||||
[%%expect{|
|
||||
Exception: Invalid_argument "index out of bounds".
|
||||
- : bool = false
|
||||
|}]
|
||||
|
||||
Path.(is_descendant (r "glob/foo") ~of_:(r "glob"))
|
||||
|
|
Loading…
Reference in New Issue