Support POSIX character classes in bracket expressions - #163
Open
dngr2 wants to merge 1 commit into
Open
Conversation
gitignore's wildmatch matches POSIX classes like [[:digit:]] and [[:alpha:]], but node-ignore turned them into a broken regex that matched nothing: the bracket scan stopped at the ']' inside [:digit:], and JS regex has no POSIX class syntax. Consume [:name:] as a unit and expand each class to its range (matching Git in the C locale). Negated and combined forms work too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
gitignore's wildmatch matches POSIX character classes inside bracket expressions —
[[:digit:]],[[:alpha:]],[[:space:]], etc. — but these currently match nothing:Two causes: the bracket scan stops at the
]that closes[:digit:](so the expression is mis-delimited), and JavaScript regex has no POSIX class syntax, so[[:digit:]]compiled to a set of the literal characters. This consumes[:name:]as a unit and expands each class to its equivalent range (matching Git in the C locale). Negated ([![:digit:]]) and combined ([[:alnum:]_]) forms work too.Added cases to the fixtures (which also run against
git check-ignore). Full suite passes at 100% coverage.