Fix ** matches to explore multiple possible matches #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #14
Previously the doublestar token would match greedily as much as it could, so for example, the double star token of the pattern
**/*/file
, when applied to a directory stringa/b/c/file
, would greedily match all ofa/b/c/file
and not leave enough for the rest of the pattern (*/file
).The solution implemented here changes the token interface so that the Consume method returns a slice of paths([]string) that the token could match. These results are added to a stack and iterated over until a solution is found. So in the above example, instead of just returning an empty slice of strings (because the
**
consumed everything), it would return the following slice:So now, the rest of the pattern (
file
) can match the second item returned.