Skip to content

Commit

Permalink
fixes #95 FilepathGlob("") should return nil
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Oct 11, 2024
1 parent da152ef commit 1e20c6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MatchTest struct {
var onWindows = runtime.GOOS == "windows"

var matchTests = []MatchTest{
{"", "", true, false, nil, true, false, true, true, 0, 0},
{"*", "", true, true, nil, false, false, true, false, 0, 0},
{"*", "/", false, false, nil, false, false, true, false, 0, 0},
{"/*", "/", true, true, nil, false, false, true, false, 0, 0},
Expand Down
10 changes: 10 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ func SplitPattern(p string) (base, pattern string) {
// filepath.ErrBadPattern.
//
func FilepathGlob(pattern string, opts ...GlobOption) (matches []string, err error) {
if pattern == "" {
// special case to match filepath.Glob behavior
g := newGlob(opts...)
if g.failOnIOErrors {
// match doublestar.Glob behavior here
return nil, os.ErrInvalid
}
return nil, nil
}

pattern = filepath.Clean(pattern)
pattern = filepath.ToSlash(pattern)
base, f := SplitPattern(pattern)
Expand Down

0 comments on commit 1e20c6d

Please sign in to comment.