diff --git a/match.go b/match.go index 69fcd05..71176e0 100644 --- a/match.go +++ b/match.go @@ -35,6 +35,9 @@ func (p pattern) match(testPath string) (bool, error) { // Normalize Windows-style path separators to forward slashes testPath = filepath.ToSlash(testPath) + // Paths are relative to the repository root, so "./foo" is the same as "foo" + testPath = strings.TrimPrefix(testPath, "./") + if p.leftAnchoredLiteral { prefix := p.pattern diff --git a/testdata/patterns.json b/testdata/patterns.json index 1006cea..d4cc9c3 100644 --- a/testdata/patterns.json +++ b/testdata/patterns.json @@ -331,5 +331,21 @@ "vllm/v1/worker/^cpu": true, "vllm/v1/worker/cpu": false } + }, + { + "name": "paths with leading dot-slash", + "pattern": "/foo/", + "paths": { + "./foo/bar": true, + "./bar/foo/baz": false + } + }, + { + "name": "anchored wildcard pattern with leading dot-slash path", + "pattern": "/src/*.go", + "paths": { + "./src/a.go": true, + "./lib/src/a.go": false + } } ] \ No newline at end of file