Skip to content

Commit 09b9aee

Browse files
committed
Globstar matches zero directories
1 parent 465a339 commit 09b9aee

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎doublestar_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ var matchTests = []MatchTest{
9999
{"[abc]", "b", true, true, nil, false, false, true, true, 3, 3},
100100
{"**", "", true, true, nil, false, false, false, false, 38, 38},
101101
{"a/**", "a", true, true, nil, false, false, false, true, 7, 7},
102+
{"a/**/", "a", true, true, nil, false, false, false, false, 4, 4},
102103
{"a/**", "a/", true, true, nil, false, false, false, false, 7, 7},
104+
{"a/**/", "a/", true, true, nil, false, false, false, false, 4, 4},
103105
{"a/**", "a/b", true, true, nil, false, false, false, true, 7, 7},
104106
{"a/**", "a/b/c", true, true, nil, false, false, false, true, 7, 7},
105107
{"**/c", "c", true, true, nil, !onWindows, false, false, true, 5, 4},

‎match.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,14 @@ MATCH:
301301
}
302302

303303
func isZeroLengthPattern(pattern string, separator rune) (ret bool, err error) {
304-
// `/**` is a special case - a pattern such as `path/to/a/**` *should* match
305-
// `path/to/a` because `a` might be a directory
306-
if pattern == "" || pattern == "*" || pattern == "**" || pattern == string(separator)+"**" {
304+
// `/**`, `**/`, and `/**/` are special cases - a pattern such as `path/to/a/**` or `path/to/a/**/`
305+
// *should* match `path/to/a` because `a` might be a directory
306+
if pattern == "" ||
307+
pattern == "*" ||
308+
pattern == "**" ||
309+
pattern == string(separator)+"**" ||
310+
pattern == "**"+string(separator) ||
311+
pattern == string(separator)+"**"+string(separator) {
307312
return true, nil
308313
}
309314

0 commit comments

Comments
 (0)