Skip to content

Commit fbcff39

Browse files
committed
Normalize Windows-style path separators to forward slashes
1 parent 09e871d commit fbcff39

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

match.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package codeowners
22

33
import (
44
"fmt"
5-
"os"
5+
"path/filepath"
66
"regexp"
77
"strings"
88
)
@@ -32,6 +32,9 @@ func newPattern(patternStr string) (pattern, error) {
3232

3333
// match tests if the path provided matches the pattern
3434
func (p pattern) match(testPath string) (bool, error) {
35+
// Normalize Windows-style path separators to forward slashes
36+
testPath = filepath.ToSlash(testPath)
37+
3538
if p.leftAnchoredLiteral {
3639
prefix := p.pattern
3740

@@ -51,7 +54,7 @@ func (p pattern) match(testPath string) (bool, error) {
5154
}
5255

5356
// Otherwise check if the test path is a subdirectory of the pattern
54-
if len(testPath) > len(prefix) && testPath[len(prefix)] == os.PathSeparator {
57+
if len(testPath) > len(prefix) && testPath[len(prefix)] == '/' {
5558
return testPath[:len(prefix)] == prefix, nil
5659
}
5760

0 commit comments

Comments
 (0)