Skip to content
Snippets Groups Projects
Commit 2264ffea authored by Agustin Chiappe Berrini's avatar Agustin Chiappe Berrini
Browse files

Fix 627

parent d932ade7
No related branches found
No related tags found
No related merge requests found
......@@ -174,7 +174,7 @@ impl Variables {
// Temporarily borrow the `swd` variable while we attempt to assemble a minimal
// variant of the directory path. If that is not possible, we will cancel the
// borrow and return `swd` itself as the minified path.
let elements = swd.split("/").collect::<Vec<&str>>();
let elements = swd.split("/").filter(|s| !s.is_empty()).collect::<Vec<&str>>();
if elements.len() > 2 {
let mut output = String::new();
for element in &elements[0..elements.len() - 1] {
......@@ -383,4 +383,18 @@ mod tests {
assert!(false);
}
}
#[test]
fn minimal_directory_var_should_compact_path() {
let mut variables = Variables::default();
variables.set_var("PWD", "/var/log/nix");
assert_eq!("v/l/nix", variables.get_var("MWD").expect("no value returned"));
}
#[test]
fn minimal_directory_var_shouldnt_compact_path() {
let mut variables = Variables::default();
variables.set_var("PWD", "/var/log");
assert_eq!("/var/log", variables.get_var("MWD").expect("no value returned"));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment