Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #88 Globstar matches zero directories #89

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ var matchTests = []MatchTest{
{"[abc]", "b", true, true, nil, false, false, true, true, 3, 3},
{"**", "", true, true, nil, false, false, false, false, 38, 38},
{"a/**", "a", true, true, nil, false, false, false, true, 7, 7},
{"a/**/", "a", true, true, nil, false, false, false, false, 4, 4},
{"a/**", "a/", true, true, nil, false, false, false, false, 7, 7},
{"a/**/", "a/", true, true, nil, false, false, false, false, 4, 4},
{"a/**", "a/b", true, true, nil, false, false, false, true, 7, 7},
{"a/**", "a/b/c", true, true, nil, false, false, false, true, 7, 7},
{"**/c", "c", true, true, nil, !onWindows, false, false, true, 5, 4},
Expand Down
11 changes: 8 additions & 3 deletions match.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,14 @@ MATCH:
}

func isZeroLengthPattern(pattern string, separator rune) (ret bool, err error) {
// `/**` is a special case - a pattern such as `path/to/a/**` *should* match
// `path/to/a` because `a` might be a directory
if pattern == "" || pattern == "*" || pattern == "**" || pattern == string(separator)+"**" {
// `/**`, `**/`, and `/**/` are special cases - a pattern such as `path/to/a/**` or `path/to/a/**/`
// *should* match `path/to/a` because `a` might be a directory
if pattern == "" ||
pattern == "*" ||
pattern == "**" ||
pattern == string(separator)+"**" ||
pattern == "**"+string(separator) ||
pattern == string(separator)+"**"+string(separator) {
return true, nil
}

Expand Down