summaryrefslogtreecommitdiff
path: root/crates/utils/string_proc/src/format_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/utils/string_proc/src/format_path.rs')
-rw-r--r--crates/utils/string_proc/src/format_path.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/utils/string_proc/src/format_path.rs b/crates/utils/string_proc/src/format_path.rs
index 152b791..35689b8 100644
--- a/crates/utils/string_proc/src/format_path.rs
+++ b/crates/utils/string_proc/src/format_path.rs
@@ -38,6 +38,11 @@ pub fn format_path_str(path: impl Into<String>) -> Result<String, std::io::Error
result.push('/');
}
+ // Special case: when result is only "./", return ""
+ if result == "./" {
+ return Ok(String::new());
+ }
+
Ok(result)
}
@@ -97,6 +102,10 @@ mod tests {
"/home/my_user/DOCS/JVCS_TEST/Vault/"
);
+ assert_eq!(format_path_str("./home/file.txt")?, "home/file.txt");
+ assert_eq!(format_path_str("./home/path/")?, "home/path/");
+ assert_eq!(format_path_str("./")?, "");
+
Ok(())
}
}