@@ -271,17 +271,27 @@ impl Scanner {
271
271
// Turn `Vec<&GlobEntry>` in `Vec<GlobEntry>`
272
272
let glob_sources: Vec < _ > = glob_sources. into_iter ( ) . cloned ( ) . collect ( ) ;
273
273
let hoisted = hoist_static_glob_parts ( & glob_sources) ;
274
+ dbg ! ( & glob_sources, & hoisted) ;
274
275
275
276
for source in & hoisted {
276
- // We need to combine the base and the pattern, otherwise a pattern that looks like
277
- // `*.html`, will never match a path that looks like
277
+ // If the pattern is empty, then the base points to a specific file or folder already
278
+ // if it doesn't contain any dynamic parts. In that case we can use the base as the
279
+ // pattern.
280
+ //
281
+ // Otherwise we need to combine the base and the pattern, otherwise a pattern that
282
+ // looks like `*.html`, will never match a path that looks like
278
283
// `/my-project/project-a/index.html`, because it contains `/`.
279
284
//
280
285
// We can't prepend `**/`, because then `/my-project/project-a/nested/index.html` would
281
286
// match as well.
282
287
//
283
288
// Instead we combine the base and the pattern as a single glob pattern.
284
- let Ok ( glob) = Glob :: new ( & format ! ( "{}/{}" , source. base, source. pattern) ) else {
289
+ let mut full_pattern = source. base . clone ( ) ;
290
+ if !source. pattern . is_empty ( ) {
291
+ full_pattern. push ( '/' ) ;
292
+ full_pattern. push_str ( & source. pattern ) ;
293
+ }
294
+ let Ok ( glob) = Glob :: new ( & full_pattern) else {
285
295
continue ;
286
296
} ;
287
297
0 commit comments