`path.escapeGlob`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
What is the problem this feature will solve?
Would allow to dynamically create glob patterns from arbitrary paths.
Example:
const pattern = `${path.escapeGlob(import.meta.dirname)}/*`;
What is the feature you are proposing to solve the problem?
Something similar in functionality to this:
// Wraps symbols which open groups `{`, `[`, `(`, and
// those with semantics independent of groups `*`, `?`
path.escapeGlob = (x = "") => x.replace(/[*{[(?]/g, "[$&]");
And this:
// inverse path.escapeGlob
path.unescapeGlob = (x = "") => x.replace(/\[.\]/g, "$&");
I was using #58988 as a reference for special chars.
What alternatives have you considered?
Using a user land package everywhere dynamic glob creation is required, or even for everything glob related to keep things consistent.
Edit: Shortened regex replacement from (...) -> $1 to ... -> $&.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading issue #58988 and the existing path API documentation and tests to understand the special characters and platform behavior already covered. Compare the proposed escaping and unescaping semantics across arbitrary paths; done requires an agreed API contract with matching implementation, tests, and documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100