@@ -35,6 +35,10 @@ func TestPathPatternMatching(t *testing.T) {
3535 {"slash prefix nested match" , "example/nested/file.txt" , "/example/" , true },
3636 {"slash prefix mismatch" , "example.txt" , "/example/" , false },
3737 {"slash prefix other dir" , "other/file.txt" , "/example/" , false },
38+ {"slash prefix no trailing slash file" , "vendor/file.go" , "/vendor" , true },
39+ {"slash prefix no trailing slash nested" , "vendor/pkg/lib.go" , "/vendor" , true },
40+ {"slash prefix no trailing slash exact" , "vendor" , "/vendor" , true },
41+ {"slash prefix no trailing slash mismatch" , "src/vendor/file.go" , "/vendor" , false },
3842 }
3943
4044 for _ , tt := range tests {
@@ -74,7 +78,7 @@ func TestPathIgnoring(t *testing.T) {
7478}
7579
7680func TestSlashPrefixPatterns (t * testing.T ) {
77- patterns := CompilePatterns ([]string {"/vendor/" , "/node_modules/" })
81+ patterns := CompilePatterns ([]string {"/vendor/" , "/node_modules/" , "/build" })
7882 tests := []struct {
7983 name string
8084 path string
@@ -84,6 +88,9 @@ func TestSlashPrefixPatterns(t *testing.T) {
8488 {"node_modules root" , "node_modules/lib/index.js" , true },
8589 {"nested vendor allowed" , "src/vendor/file.go" , false },
8690 {"other directory" , "src/main.go" , false },
91+ {"build no trailing slash" , "build/output.js" , true },
92+ {"build exact" , "build" , true },
93+ {"nested build allowed" , "src/build/output.js" , false },
8794 }
8895
8996 for _ , tt := range tests {
@@ -96,10 +103,10 @@ func TestSlashPrefixPatterns(t *testing.T) {
96103}
97104
98105func TestCompiledPatterns (t * testing.T ) {
99- patterns := CompilePatterns ([]string {"*.txt" , "ignore/" , "temp/*.log" , "**.min.css" , "/vendor/" })
106+ patterns := CompilePatterns ([]string {"*.txt" , "ignore/" , "temp/*.log" , "**.min.css" , "/vendor/" , "/build" })
100107
101- if len (patterns ) != 5 {
102- t .Errorf ("Expected 5 compiled patterns, got %d" , len (patterns ))
108+ if len (patterns ) != 6 {
109+ t .Errorf ("Expected 6 compiled patterns, got %d" , len (patterns ))
103110 }
104111
105112 for _ , p := range patterns {
@@ -127,6 +134,13 @@ func TestCompiledPatterns(t *testing.T) {
127134 if p .prefix != "vendor/" {
128135 t .Errorf ("/vendor/ prefix should be 'vendor/', got %q" , p .prefix )
129136 }
137+ case "/build" :
138+ if ! p .isSlashPrefix {
139+ t .Error ("/build should be marked as slash prefix" )
140+ }
141+ if p .prefix != "build" {
142+ t .Errorf ("/build prefix should be 'build', got %q" , p .prefix )
143+ }
130144 }
131145 }
132146}
0 commit comments