Skip to content

fix: escape square brackets in glob paths#913

Closed
ruguoba wants to merge 1 commit into
unplugin:mainfrom
ruguoba:fix/escape-square-brackets
Closed

fix: escape square brackets in glob paths#913
ruguoba wants to merge 1 commit into
unplugin:mainfrom
ruguoba:fix/escape-square-brackets

Conversation

@ruguoba

@ruguoba ruguoba commented May 15, 2026

Copy link
Copy Markdown

Problem

When the file path contains square brackets (e.g. FiveM resource groups like [GoodCategoryName]), the matchGlobs function fails because picomatch interprets [Resource] as a character class.

Root Cause

The escapeSpecialChars function in src/core/utils.ts only escapes parentheses () but not square brackets [].

Fix

Added square brackets to the escape regex:

- const ESCAPE_PARENTHESES_REGEX = /[()]/g
+ const ESCAPE_SPECIAL_CHARS_REGEX = /[()[\]]/g

This ensures paths like C:/Github/Project/[Resource]/ui/src/component/**/*.vue are properly escaped before matching.

Fixes #810

The escapeSpecialChars function only escaped parentheses () but not
square brackets []. This caused picomatch to interpret [Resource] as
a character class when path contained directories with square brackets
(e.g. FiveM resource groups like [GoodCategoryName]).

Fixes #810
@ruguoba ruguoba requested a review from antfu as a code owner May 15, 2026 02:12
@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

@pkg-pr-new

pkg-pr-new Bot commented May 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-vue-components@913

commit: 301922a

@ruguoba

ruguoba commented May 18, 2026

Copy link
Copy Markdown
Author

Closing this PR as it's no longer needed.

@ruguoba ruguoba closed this May 18, 2026
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.

Square brackets in resolved base path leads to matchGlobs in watcher to fails

1 participant