diff --git a/src/lib.rs b/src/lib.rs index 314c078..1ba8fa7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,7 +178,15 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result bool { match p.components().next() { - Some(Component::Prefix(ref p)) => p.kind().is_verbatim(), + Some(Component::Prefix(ref p)) => { + // Allow VerbatimDisk paths. std canonicalize() generates them, and they work fine + p.kind().is_verbatim() + && if let std::path::Prefix::VerbatimDisk(_) = p.kind() { + false + } else { + true + } + } _ => false, } } diff --git a/tests/glob-std.rs b/tests/glob-std.rs index 085eb6d..d208a4a 100644 --- a/tests/glob-std.rs +++ b/tests/glob-std.rs @@ -91,6 +91,25 @@ fn main() { ) ); + // std-canonicalized windows verbatim disk paths should work + if env::consts::FAMILY == "windows" { + let r_verbatim = PathBuf::from("r").canonicalize().unwrap(); + assert_eq!( + glob_vec(&format!("{}\\**", r_verbatim.display().to_string())) + .into_iter() + .map(|p| p.strip_prefix(&r_verbatim).unwrap().to_owned()) + .collect::>(), + vec!( + PathBuf::from("another"), + PathBuf::from("one"), + PathBuf::from("one\\another"), + PathBuf::from("one\\another\\deep"), + PathBuf::from("three"), + PathBuf::from("two") + ) + ); + } + // collapse consecutive recursive patterns assert_eq!( glob_vec("r/**/**"),