Skip to content

Commit

Permalink
Fixed bug in pattern matching for patterns containing a star. (#1129)
Browse files Browse the repository at this point in the history
Fixes #961
  • Loading branch information
alphaleonis committed Jun 12, 2021
1 parent 7735fcc commit 42c59cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/wcmatch/wcmatch.go
Expand Up @@ -382,7 +382,8 @@ func doMatch(tokens []token, text []rune, ignoreCase bool) matchResult {
return wcNoMatch
}

t.pos = slashIndex
// Skip all characters up to the upcoming directory sep.
t.pos += slashIndex - 1

break
}
Expand Down
7 changes: 7 additions & 0 deletions internal/wcmatch/wcmatch_test.go
Expand Up @@ -65,6 +65,7 @@ func TestMatchWithBaseDir(t *testing.T) {

func TestMatch(t *testing.T) {
cases := []wcCase{

// Basic
{"", "", true, true},
{"*", "", true, true},
Expand Down Expand Up @@ -174,6 +175,12 @@ func TestMatch(t *testing.T) {
{" \tfoo", "foo", true, true},
{" foo ", "foo", true, true},
{" foo\\ ", "/foo ", true, true},

{"/users/user1/logs", "/users/user1/logs", true, true},
{"/users/**/logs", "/users/user1/logs", true, true},
{"/users/user?/logs", "/users/user1/logs", true, true},
{"/users/user*/logs", "/users/user1/logs", true, true},
{"/users/*/logs", "/users/user1/logs", true, true},
}

testHelper(t, cases)
Expand Down

0 comments on commit 42c59cb

Please sign in to comment.