Skip to content

Commit

Permalink
Fix behavior when multiple glob patterns are specified
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Dec 5, 2024
1 parent 84aa7f2 commit 1051d2d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 51 deletions.
21 changes: 10 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,17 @@ const createPathTester = patterns => {
const wildcardPatterns = patterns.filter(pattern => pattern.includes('*')).map(pattern => pattern.toLowerCase());

const regularPatternsSet = new Set(regularPatterns);
const wildcardRegExp = new RegExp(
`^(${wildcardPatterns.map(pattern =>
// Escape regex special characters.
escapeRegExp(pattern)
// Handle `**` feature.
.replaceAll('\\.\\*\\*\\.', '\\..*')
.replaceAll('\\*\\*\\.', '(.*\\.)?')
.replaceAll('\\*\\*', '.*')
// Handle `*` feature.
.replaceAll('\\*', '[^\\.]*')
)})$`
const wildcardRegExpParts = wildcardPatterns.map(pattern =>
// Escape regex special characters.
escapeRegExp(pattern)
// Handle `**` feature.
.replaceAll('\\.\\*\\*\\.', '\\..*')
.replaceAll('\\*\\*\\.', '(.*\\.)?')
.replaceAll('\\*\\*', '.*')
// Handle `*` feature.
.replaceAll('\\*', '[^\\.]*')
);
const wildcardRegExp = new RegExp(`^(${wildcardRegExpParts.join('|')})$`);

return path => {
const lowercasedPath = path.toLowerCase();
Expand Down
Loading

0 comments on commit 1051d2d

Please sign in to comment.