codi-test-framework
Advanced tools
Comparing version 0.0.29 to 0.0.30
{ | ||
"name": "codi-test-framework", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "A simple test framework for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "src/testRunner.js", |
export function excludePattern(patterns) { | ||
return (path) => { | ||
return patterns.some(pattern => { | ||
// Normalize path separators | ||
const normalizedPattern = pattern.replace(/[\\/]+/g, '/'); | ||
const normalizedPath = path.replace(/[\\/]+/g, '/'); | ||
// Escape special regex characters in the pattern | ||
const regexPattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
// Create a regex that matches the pattern at the start, optionally followed by '/' | ||
const regex = new RegExp(`^${regexPattern}($|/)`); | ||
return regex.test(path); | ||
const regexPattern = normalizedPattern | ||
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | ||
.replace(/\//g, '[\\\\/]'); // Allow both / and \ as separators | ||
// Create a regex that matches the pattern at the start, optionally followed by a separator | ||
const regex = new RegExp(`^${regexPattern}($|[\\\\/])`); | ||
return regex.test(normalizedPath); | ||
}); | ||
}; | ||
} |
17687
265