fix(kaos): match globstar zero directories - #2287
Conversation
🦋 Changeset detectedLatest commit: c61d3d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c61d3d5418
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (pattern[i + 1] === '*' && pattern[i + 2] === '/') { | ||
| regex += '(?:[^/]+/)*'; | ||
| i += 2; |
There was a problem hiding this comment.
Treat globstar only as a full path segment
When callers pass a full pattern containing a path component like ***/foo.txt or a**/foo.txt, this branch fires on the last two * characters and turns that non-globstar component into (?:[^/]+/)*, so it can match zero or multiple directories. In Python-style glob semantics only a component that is exactly ** is recursive; these patterns should stay within a single path segment. Please require the **/ to start a segment, e.g. at index 0 or immediately after /, before applying the recursive rewrite.
Useful? React with 👍 / 👎.
Related Issue
No linked issue.
Problem
**/foopatterns did not match files in the starting directory, so recursive globs missed valid files at the root of the search.What changed
Teach the glob regex helper to treat
**/as zero-or-more directories and add coverage for both leading and middle**/cases.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.