Skip to content

Commit 5305187

Browse files
committed
fix: use path.Clean for slash-normalized glob patterns
filepath.Clean uses the OS-native separator, so on Windows it re-introduced backslashes after filepath.ToSlash, producing patterns like "apps\*" that the gobwas glob (compiled with '/' as separator) could never match. Switching to path.Clean keeps patterns slash- separated on every platform, fixing TestClassifier_Classify path cases and TestDiscovery_AttributeFilters/path_filter_*.
1 parent 5a47467 commit 5305187

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

internal/filter/ast.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package filter
22

33
import (
4+
"path"
45
"path/filepath"
56
"strconv"
67

@@ -37,7 +38,7 @@ type PathExpression struct {
3738

3839
// NewPathFilter creates a new PathFilter with eager glob compilation.
3940
func NewPathFilter(value string) (*PathExpression, error) {
40-
pattern := filepath.Clean(filepath.ToSlash(value))
41+
pattern := path.Clean(filepath.ToSlash(value))
4142

4243
compiled, err := glob.Compile(pattern)
4344
if err != nil {
@@ -75,7 +76,7 @@ func NewAttributeExpression(key string, value string) (*AttributeExpression, err
7576
pattern := value
7677

7778
if key == AttributeReading {
78-
pattern = filepath.Clean(filepath.ToSlash(pattern))
79+
pattern = path.Clean(filepath.ToSlash(pattern))
7980
}
8081

8182
compiled, err := glob.Compile(pattern)

0 commit comments

Comments
 (0)