Skip to content

Fix optional trailing slash for prefix star fast path - #216

Closed
SparkUiX wants to merge 1 commit into
micromatch:masterfrom
SparkUiX:codex/fastpath-trailing-slash
Closed

SparkUiX wants to merge 1 commit into
micromatch:masterfrom
SparkUiX:codex/fastpath-trailing-slash

Conversation

@SparkUiX

Copy link
Copy Markdown

Summary

Align the prefix-star fast path with the full parser for an optional trailing slash. With default options, isMatch('foo/', 'foo*') returned false, while fastpaths: false returned true. The existing * behavior already accepts a/ unless strictSlashes is enabled.

The fast path now adds the optional slash only when its generated expression ends in an unescaped star. Escaped stars, strictSlashes: true, and paths with an additional segment keep their behavior.

This addresses the secondary fast-path divergence noted in #207. PR #208 handles the separate *.* case.

Reproduction and verification

  • New regression test failed before the fix: 0 passing, 1 failing at assert(isMatch('foo/', pattern)).
  • npx mocha test/stars.js --reporter dot: 18 passing.
  • npm run mocha -- --reporter dot: 1999 passing.
  • npm run lint and git diff --check: passed.
  • Compared default and fastpaths: false for the affected patterns under default, strictSlashes, capture, bash, and Windows options: no remaining differences in the checked cases.

Prepared with OpenAI Codex assistance. The change has not yet received human review.

@jonschlinkert

Copy link
Copy Markdown
Member

Prepared with OpenAI Codex assistance. The change has not yet received human review.

Not wasting time on this

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.

2 participants