Skip to content

Commit

Permalink
fix(src/path_env.rs): Issue 2504: Fix for JoinPathsError (#2511)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallaway authored Aug 27, 2024
1 parent 6897258 commit 270adb8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/path_env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env::join_paths;
use std::env::split_paths;
use std::ffi::OsString;
use std::fmt;
use std::fmt::{Display, Formatter};
Expand Down Expand Up @@ -27,7 +28,9 @@ impl PathEnv {
}

pub fn add(&mut self, path: PathBuf) {
self.mise.push(path);
for part in split_paths(&path) {
self.mise.push(part);
}
}

pub fn to_vec(&self) -> Vec<PathBuf> {
Expand Down Expand Up @@ -139,4 +142,11 @@ mod tests {
format!("/1:/2:/3:/before-1:/before-2:/before-3:/after-1:/after-2:/after-3")
);
}
#[test]
fn test_path_env_with_colon() {
reset();
let mut path_env = PathEnv::from_iter(["/item1", "/item2"].map(PathBuf::from));
path_env.add("/1:/2".into());
assert_eq!(path_env.to_string(), format!("/1:/2:/item1:/item2"));
}
}

0 comments on commit 270adb8

Please sign in to comment.