Skip to content

scan: report isGlobstar without scanToEnd - #204

Open
lenamonj wants to merge 1 commit into
micromatch:masterfrom
lenamonj:fix-scan-isglobstar
Open

scan: report isGlobstar without scanToEnd#204
lenamonj wants to merge 1 commit into
micromatch:masterfrom
lenamonj:fix-scan-isglobstar

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 1, 2026

Copy link
Copy Markdown

picomatch.scan('**').isGlobstar is false, and so is scan('foo/**/*.js').isGlobstar; the same inputs with { scanToEnd: true } report true.

Cause: without scanToEnd the loop finishes at the first *, and isGlobstar was only set when the previous character was a star, so it could only ever be seen from the second one.

Change: also check peek() for the next character. One line, plus a test for the default-options path (the existing globstar tests all pass scanToEnd: true).

Verified: npm test 1999 passing (the new test fails on master).

Found by an automated code-review loop I run; the fix and this description were prepared with Claude and verified by hand.

Without scanToEnd the scan loop stops at the first star, and isGlobstar was
only ever set from the second one, so scan('**').isGlobstar was false while
scan('**', { scanToEnd: true }).isGlobstar was true. Look ahead as well as
behind.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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