Skip to content

fix: escape special characters in glob patterns #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

ilyaliao
Copy link
Contributor

@ilyaliao ilyaliao commented Jul 12, 2025

Description

This PR escapes special characters in glob patterns when searching for components, fixing potential matching issues when component paths contain characters like [], (), or {}.

Please refer to picomatch docs and fast-glob issue for more context.

Linked Issues

resolved: #779
resolved: #822
closed: #832

@ilyaliao ilyaliao requested a review from antfu as a code owner July 12, 2025 20:47
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ilyaliao ilyaliao marked this pull request as draft July 12, 2025 21:05
@ilyaliao
Copy link
Contributor Author

ilyaliao commented Jul 12, 2025

I removed slash since it transforms \\(3\\) to /(3/). However, it seems necessary for Windows environments.

I need to investigate how to handle this properly.

@ilyaliao ilyaliao marked this pull request as ready for review July 16, 2025 20:15
@ilyaliao
Copy link
Contributor Author

ilyaliao commented Jul 16, 2025

I made some modifications after the initial implementation. Originally, I used escapePath provided by tinyglobby, but it handles other special characters beyond (), like **, which would render the processed path unusable.

For example:

unplugin-vue-components/src/components/**/*.vue
↓
unplugin-vue-components/src/components/\*\*/\*.vue

Therefore, I created a new escapeSpecialChars function specifically to handle (). We can expand this function to handle additional characters as needed in the future.

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.

项目目录存在英文括号(),AutoComponents本地运行异常 default resolver failed to resolve components with components folder
1 participant