This commit is contained in:
Abhay J Nayak 2026-05-22 00:14:53 +05:30 committed by GitHub
commit 41ae471f68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 1 deletions

View File

@ -83,7 +83,10 @@ impl<'a> Stream<'a> {
None => return true,
};
let path = util::to_lowercase(path);
let mut path = util::to_lowercase(path);
if cfg!(windows) {
path = path.replace('\\', "/");
}
let mut path = path.as_str();
match path.rfind(keywords_last) {
Some(idx) => {
@ -208,4 +211,16 @@ mod tests {
let stream = Stream::new(db, options);
assert_eq!(is_match, stream.filter_by_keywords(path));
}
// Forward slash matching on Windows-style paths
#[cfg(windows)]
#[rstest]
#[case(&["bar/meow"], r"~\foo\bar\meow", true)]
#[case(&["bar", "meow"], r"~\foo\bar\meow", true)]
fn query_windows(#[case] keywords: &[&str], #[case] path: &str, #[case] is_match: bool) {
let db = &mut Database::new(PathBuf::new(), Vec::new(), |_| Vec::new(), false);
let options = StreamOptions::new(0).with_keywords(keywords.iter());
let stream = Stream::new(db, options);
assert_eq!(is_match, stream.filter_by_keywords(path));
}
}