Skip to content

fix(html): don't treat a directory as the html file for a query url - #23693

Closed
india3Eth wants to merge 1 commit into
vitejs:mainfrom
india3Eth:fix/html-query-directory-watch
Closed

india3Eth wants to merge 1 commit into
vitejs:mainfrom
india3Eth:fix/html-query-directory-watch

Conversation

@india3Eth

Copy link
Copy Markdown

fixes #23679

Since #23653 getHtmlFilename() strips the query, so transformIndexHtml('/?foo=bar', html) gets the root directory as filename. devHtmlHook only checked fs.existsSync(filename), which is true for a directory, so the URL was treated as a real HTML file and the inline <style> proxy module ended up with mod.file === '/', and ensureWatchedFile added / to the watcher.

It now requires filename to be a file (tryStatSync(filename)?.isFile()), so this case goes back to the virtual \0 proxy path it used before 8.3.3. I went with that over computing trailingSlash from the stripped path, since /?foo=bar + index.html would need extra handling to put index.html before the query.

Test in indexHtml.spec.ts: calls transformIndexHtml('/?foo=bar', …) with an inline <style> and asserts no directory gets watched. On main it watches /.

AI disclosure: I used an AI coding tool to help write this. I reviewed the change, checked the test fails without the fix, and ran the packages/vite unit tests (no new failures).

@github-actions github-actions Bot added the bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This PR has been automatically flagged as likely to be created by a bot, LLM, or agent, and will be automatically closed. These contributions harm the maintenance of the project. Please read our AI policy for more information.

If you believe this is a mistake, please reply to this comment and we will review it.

@github-actions github-actions Bot closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformIndexHtml('/?query') adds the filesystem root to the watcher since 8.3.3

1 participant