mirror of
https://github.com/agersant/polaris
synced 2024-12-02 17:49:10 +00:00
Fixed a bug where most mount directory paths didn't work on Windows
This commit is contained in:
parent
6cd9f94b85
commit
87c4763cd1
1 changed files with 6 additions and 8 deletions
|
@ -192,19 +192,17 @@ impl Config {
|
|||
}
|
||||
|
||||
fn clean_path_string(path_string: &str) -> path::PathBuf {
|
||||
let separator = regex::Regex::new(r"\\|/").unwrap();
|
||||
let components = separator.split(path_string).collect::<Vec<_>>();
|
||||
let mut path = path::PathBuf::new();
|
||||
for component in components {
|
||||
path.push(component);
|
||||
}
|
||||
path
|
||||
let separator_regex = regex::Regex::new(r"\\|/").unwrap();
|
||||
let mut correct_separator = String::new();
|
||||
correct_separator.push(path::MAIN_SEPARATOR);
|
||||
let path_string = separator_regex.replace_all(path_string, correct_separator.as_str());
|
||||
path::PathBuf::from(path_string)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_clean_path_string() {
|
||||
let mut correct_path = path::PathBuf::new();
|
||||
correct_path.push("C:");
|
||||
correct_path.push("C:\\");
|
||||
correct_path.push("some");
|
||||
correct_path.push("path");
|
||||
assert_eq!(correct_path, clean_path_string(r#"C:/some/path"#));
|
||||
|
|
Loading…
Reference in a new issue