Skip to content

Commit 1e20c6d

Browse files
committed
fixes #95 FilepathGlob("") should return nil
1 parent da152ef commit 1e20c6d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

doublestar_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type MatchTest struct {
2828
var onWindows = runtime.GOOS == "windows"
2929

3030
var matchTests = []MatchTest{
31+
{"", "", true, false, nil, true, false, true, true, 0, 0},
3132
{"*", "", true, true, nil, false, false, true, false, 0, 0},
3233
{"*", "/", false, false, nil, false, false, true, false, 0, 0},
3334
{"/*", "/", true, true, nil, false, false, true, false, 0, 0},

utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ func SplitPattern(p string) (base, pattern string) {
8484
// filepath.ErrBadPattern.
8585
//
8686
func FilepathGlob(pattern string, opts ...GlobOption) (matches []string, err error) {
87+
if pattern == "" {
88+
// special case to match filepath.Glob behavior
89+
g := newGlob(opts...)
90+
if g.failOnIOErrors {
91+
// match doublestar.Glob behavior here
92+
return nil, os.ErrInvalid
93+
}
94+
return nil, nil
95+
}
96+
8797
pattern = filepath.Clean(pattern)
8898
pattern = filepath.ToSlash(pattern)
8999
base, f := SplitPattern(pattern)

0 commit comments

Comments
 (0)