Skip to content

parse: honor noglobstar on the leading **/ fast path - #205

Open
lenamonj wants to merge 1 commit into
micromatch:masterfrom
lenamonj:fix-noglobstar-fastpath
Open

parse: honor noglobstar on the leading **/ fast path#205
lenamonj wants to merge 1 commit into
micromatch:masterfrom
lenamonj:fix-noglobstar-fastpath

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 1, 2026

Copy link
Copy Markdown

With { noglobstar: true }, isMatch('a', '**/*') is true while isMatch('a', '*/*') is false; '**/*.js' matches x.js the same way. noglobstar is documented as disabling **, so a leading **/ should be one required segment.

Cause: the fast-path create() cases for **/*, **/*.js and **/.* wrap the leading **/ in (?:...)? whatever the option says. The ** case alone was fixed for #20; the prefixed forms were not.

Change: skip the fast path for a leading **/ when noglobstar is set, so the full parser builds it (as it already does for ** next to a literal extension). Four lines, plus a test.

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.

The fast-path cases for `**/*` and friends wrap the leading `**/` in an
optional group regardless of `noglobstar`, so `**/*` matched a single-segment
path that `*/*` rejects under the same option. Skip the fast path for a
leading `**/` when noglobstar is set and let the full parser build it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lenamonj
lenamonj force-pushed the fix-noglobstar-fastpath branch from 58cd2a4 to 7267d5b Compare September 1, 2026 23:42
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