Skip to content

fix: preserve Windows input paths with glob-special segment names - #23409

Open
gilangabdian wants to merge 1 commit into
vitejs:mainfrom
gilangabdian:fix/windows-input-paths-glob-characters
Open

fix: preserve Windows input paths with glob-special segment names #23409
gilangabdian wants to merge 1 commit into
vitejs:mainfrom
gilangabdian:fix/windows-input-paths-glob-characters

Conversation

@gilangabdian

@gilangabdian gilangabdian commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

fixes #23383

On Windows, paths like D:\desk\test\@src\whatever.html or D:\desk\test\[id]\page.html
crash Vite with [UNRESOLVED_ENTRY].

Root Cause

unescapeGlobCharacters() calls isDynamicPattern(value) on the raw input before
any Windows check. On Windows, \ is the path separator — not an escape character —
so D:\test\[id] is misinterpreted as a glob pattern and throws.

// Before
function unescapeGlobCharacters(value: string): string {
  if (isDynamicPattern(value)) { // ← crashes for D:\test\[id]
    throw new Error(...)
  }
  // isWindows check never reached for paths with [ or (
}

Fix

Add if (isWindows) return value at the top of unescapeGlobCharacters to skip all glob processing on Windows (backslash is a path separator, not an escape character).
Refine escapedGlobCharactersRE to only match extglob modifiers (@, +, !) when followed by (, aligning with tinyglobby's extglob support.
Add a hasUnescapedGlob helper that strips valid escapes before calling isDynamicPattern, so valid glob escapes on POSIX are handled correctly.

Other PRs / Alternatives

There is an existing local branch chris/fix/windows-input-glob-unescape with a similar approach. However, it places if (isWindows) after isDynamicPattern(value), so paths with [ or ( segments (e.g. D:\test\[id]\page.html) still crash. Our fix places the guard at the very top, making it work for all glob-special characters.

i also add a unit test to make sure this change is saved and doesn't break the existing codebase:
Added unit tests in config.spec.ts (guarded by isWindows so they only run on Windows CI) covering all affected path patterns:

  • D:\desk\test\@src\whatever.html
  • D:\desk\test\!notes\page.html
  • D:\desk\test\+draft\page.html
  • D:\desk\test\(draft)\page.html ← would still fail with the other approach
  • D:\desk\test\[id]\page.html ← would still fail with the other approach

@gilangabdian
gilangabdian force-pushed the fix/windows-input-paths-glob-characters branch from 5773a92 to ff1259c Compare September 1, 2026 05:00
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.

Dependency scan fails with incorrect file path when input contains @ in directory name on Windows

1 participant