From d0efb45d33a523401cc444e83e6f32bf77a29855 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 28 Oct 2024 19:49:22 +0100 Subject: [PATCH] ensure the patterns are prepended with the base This is to ensure that matching files is correct. --- crates/oxide/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/oxide/src/lib.rs b/crates/oxide/src/lib.rs index 1789322ec..7d6f5caaf 100644 --- a/crates/oxide/src/lib.rs +++ b/crates/oxide/src/lib.rs @@ -273,7 +273,15 @@ impl Scanner { let hoisted = hoist_static_glob_parts(&glob_sources); for source in &hoisted { - let Ok(glob) = Glob::new(&source.base) else { + // We need to combine the base and the pattern, otherwise a pattern that looks like + // `*.html`, will never match a path that looks like + // `/my-project/project-a/index.html`, because it contains `/`. + // + // We can't prepend `**/`, because then `/my-project/project-a/nested/index.html` would + // match as well. + // + // Instead we combine the base and the pattern as a single glob pattern. + let Ok(glob) = Glob::new(&format!("{}/{}", source.base, source.pattern)) else { continue; };