Replace invalid characters in filenames (Windows only, fixes #3)

This commit is contained in:
FliegendeWurst 2020-12-10 08:39:08 +01:00
parent 58078fc2cf
commit 6b1e6cb9a6

View File

@ -1055,6 +1055,11 @@ impl URL {
}
}
#[cfg(not(target_os = "windows"))]
const INVALID: &'static [char] = &['/', '\\'];
#[cfg(target_os = "windows")]
const INVALID: &'static [char] = &['/', '\\', ':', '<', '>', '"', '|', '?', '*'];
fn file_escape(s: &str) -> String {
s.replace('/', "-").replace('\\', "-")
s.replace(INVALID, "-")
}