mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +00:00
Make sure CurDir
is filtered out in absolutize. (#3084)
* Make sure `CurDir` is filtered out in absolutize. Closes #3083 * Add test * Make sure test works on windows
This commit is contained in:
parent
e834e617f3
commit
7f303a856e
1 changed files with 15 additions and 1 deletions
|
@ -29,7 +29,10 @@ where
|
||||||
|
|
||||||
(absolute, relative)
|
(absolute, relative)
|
||||||
} else {
|
} else {
|
||||||
(relative_to.as_ref().to_path_buf(), path)
|
(
|
||||||
|
relative_to.as_ref().to_path_buf(),
|
||||||
|
components.iter().collect::<PathBuf>(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,6 +94,17 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn absolutize_with_curdir() {
|
||||||
|
let relative_to = Path::new("/foo");
|
||||||
|
let path = Path::new("./bar/./baz");
|
||||||
|
|
||||||
|
assert!(!absolutize(relative_to, path)
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
.contains("."));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn canonicalize_should_succeed() -> io::Result<()> {
|
fn canonicalize_should_succeed() -> io::Result<()> {
|
||||||
let relative_to = Path::new("/foo/bar");
|
let relative_to = Path::new("/foo/bar");
|
||||||
|
|
Loading…
Reference in a new issue