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 {
|
fn clean_path_string(path_string: &str) -> path::PathBuf {
|
||||||
let separator = regex::Regex::new(r"\\|/").unwrap();
|
let separator_regex = regex::Regex::new(r"\\|/").unwrap();
|
||||||
let components = separator.split(path_string).collect::<Vec<_>>();
|
let mut correct_separator = String::new();
|
||||||
let mut path = path::PathBuf::new();
|
correct_separator.push(path::MAIN_SEPARATOR);
|
||||||
for component in components {
|
let path_string = separator_regex.replace_all(path_string, correct_separator.as_str());
|
||||||
path.push(component);
|
path::PathBuf::from(path_string)
|
||||||
}
|
|
||||||
path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clean_path_string() {
|
fn test_clean_path_string() {
|
||||||
let mut correct_path = path::PathBuf::new();
|
let mut correct_path = path::PathBuf::new();
|
||||||
correct_path.push("C:");
|
correct_path.push("C:\\");
|
||||||
correct_path.push("some");
|
correct_path.push("some");
|
||||||
correct_path.push("path");
|
correct_path.push("path");
|
||||||
assert_eq!(correct_path, clean_path_string(r#"C:/some/path"#));
|
assert_eq!(correct_path, clean_path_string(r#"C:/some/path"#));
|
||||||
|
|
Loading…
Add table
Reference in a new issue