Fix glob pattern matching on Windows by converting paths to forward slashes

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-10 23:31:29 +00:00
co-authored by salmanmkc
parent 92cb8ef23c
commit 0483fce47e
20 changed files with 13 additions and 93544 deletions
+12 -1
View File
@@ -156,6 +156,12 @@ export class Pattern {
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath)
}
// Convert to forward slashes on Windows before matching with minimatch
// since the pattern was converted to forward slashes in the constructor
if (IS_WINDOWS) {
itemPath = itemPath.replace(/\\/g, '/')
}
// Match
if (this.minimatch.match(itemPath)) {
return this.trailingSeparator ? MatchKind.Directory : MatchKind.All
@@ -176,8 +182,13 @@ export class Pattern {
return this.rootRegExp.test(itemPath)
}
// Convert to forward slashes on Windows to match the pattern format used by minimatch
if (IS_WINDOWS) {
itemPath = itemPath.replace(/\\/g, '/')
}
return this.minimatch.matchOne(
itemPath.split(IS_WINDOWS ? /\\+/ : /\/+/),
itemPath.split(/\/+/),
this.minimatch.set[0],
true
)