Fix path_contains_hidden_folder (#6173)

* Fix path_contains_hidden_folder

Signed-off-by: nibon7 <nibon7@163.com>

* add test

Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
nibon7
2022-08-04 09:59:57 +08:00
committed by GitHub
parent 87823b0cb5
commit 7c49a42b68
2 changed files with 26 additions and 5 deletions

View File

@ -343,11 +343,7 @@ fn is_hidden_dir(dir: impl AsRef<Path>) -> bool {
}
fn path_contains_hidden_folder(path: &Path, folders: &[PathBuf]) -> bool {
let path_str = path.to_str().expect("failed to read path");
if folders
.iter()
.any(|p| path_str.starts_with(&p.to_str().expect("failed to read hidden paths")))
{
if folders.iter().any(|p| path.starts_with(p.as_path())) {
return true;
}
false