Skip to content

Support POSIX character classes in bracket expressions - #163

Open
dngr2 wants to merge 1 commit into
kaelzhang:masterfrom
dngr2:posix-character-classes
Open

Support POSIX character classes in bracket expressions#163
dngr2 wants to merge 1 commit into
kaelzhang:masterfrom
dngr2:posix-character-classes

Conversation

@dngr2

@dngr2 dngr2 commented Aug 17, 2026

Copy link
Copy Markdown

gitignore's wildmatch matches POSIX character classes inside bracket expressions — [[:digit:]], [[:alpha:]], [[:space:]], etc. — but these currently match nothing:

ignore().add('[[:digit:]].log').ignores('1.log')  // false; git ignores it

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant