This commit is contained in:
2025-05-29 13:35:36 +00:00
parent 756964aabd
commit 960bbc2208
15 changed files with 2373 additions and 3396 deletions

View File

@ -119,9 +119,23 @@ export class CorpusLoader {
for (const cat of categoriesToSearch) {
const categoryFiles = await this.loadCategory(cat);
const matchingFiles = categoryFiles.filter(file =>
path.basename(file.path).match(pattern.replace('*', '.*'))
);
const matchingFiles = categoryFiles.filter(file => {
// Convert glob pattern to regex pattern
const regexPattern = pattern
.replace(/\*\*/g, '@@DOUBLESTAR@@') // Temporarily replace **
.replace(/\*/g, '[^/]*') // Replace * with "any character except /"
.replace(/@@DOUBLESTAR@@/g, '.*') // Replace ** with "any character"
.replace(/\//g, '\\/') // Escape forward slashes
.replace(/\./g, '\\.'); // Escape dots
try {
const regex = new RegExp(regexPattern);
return regex.test(file.path);
} catch (e) {
// If regex fails, try simple includes match
return file.path.includes(pattern.replace(/\*/g, ''));
}
});
files.push(...matchingFiles);
}