fixes #95 FilepathGlob("") should return nil
diff --git a/doublestar_test.go b/doublestar_test.go
index 26ff894..bf6414e 100644
--- a/doublestar_test.go
+++ b/doublestar_test.go
@@ -28,6 +28,7 @@
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},
diff --git a/utils.go b/utils.go
index 0ab1dc9..6b8df9a 100644
--- a/utils.go
+++ b/utils.go
@@ -84,6 +84,16 @@
// 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)