Skip to content

Commit

Permalink
fix: glob match on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Jun 4, 2024
1 parent b8166da commit 7bfd1cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (f Finder) Find(fsys afero.Fs) ([]string, error) {

// pool.Go(func() ([]string, error) {
// // If the name contains any glob character, perform a glob match
// if strings.ContainsAny(searchName, "*?[]\\^") {
// if strings.ContainsAny(searchName, globMatch) {
// return globWalkSearch(fsys, searchPath, searchName, f.Type)
// }
//
Expand All @@ -79,7 +79,7 @@ func (f Finder) Find(fsys afero.Fs) ([]string, error) {

allResults, err := iter.MapErr(searchItems, func(item *searchItem) ([]string, error) {
// If the name contains any glob character, perform a glob match
if strings.ContainsAny(item.name, "*?[]\\^") {
if strings.ContainsAny(item.name, globMatch) {
return globWalkSearch(fsys, item.path, item.name, f.Type)
}

Expand Down
5 changes: 5 additions & 0 deletions glob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !windows

package locafero

const globMatch = "*?[]\\^"
8 changes: 8 additions & 0 deletions glob_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build windows

package locafero

// See [filepath.Match]:
//
// On Windows, escaping is disabled. Instead, '\\' is treated as path separator.
const globMatch = "*?[]^"

0 comments on commit 7bfd1cc

Please sign in to comment.