Skip to content

Commit

Permalink
Make filename globs case-insensitive (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov authored May 18, 2021
1 parent 12ad491 commit 9f5e452
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,11 @@ func FilterGlob(vs []string, matcher string) []string {
return vs
}

g := glob.MustCompile(matcher)
g := glob.MustCompile(strings.ToLower(matcher))

vsf := make([]string, 0)
for _, v := range vs {
if res := g.Match(v); res {
if res := g.Match(strings.ToLower(v)); res {
vsf = append(vsf, v)
}
}
Expand Down
16 changes: 16 additions & 0 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestFilterGlob(t *testing.T) {
files := []string{"path/to/file.jpg", "path/to/file.png", "path/to/file.go", "path/to/another-file.JPG"}
pattern := "*.{jpg,PNG}"
result := FilterGlob(files, pattern)

expected := []string{"path/to/file.jpg", "path/to/file.png", "path/to/another-file.JPG"}
assert.ElementsMatch(t, expected, result)
}

0 comments on commit 9f5e452

Please sign in to comment.