vite
vite copied to clipboard
Invalid script path rewrite when folder starts with dot
Describe the bug
If index.html
includes <script type="module" src=".test/main.js"></script>
, the dev html hook is going to replace src by /test/main.js
(which will 404) whenever the URL is different from /
(e.g. /?foo
will fail, so will /whatever
, but /
will be ok).
Using abosolute src="/.test/main.js"
will also work.
Failing code below:
(Meant to handle ./index.js
and ../index.js
, but will also trip over .test/main.js
)
Reproduction
https://stackblitz.com/edit/vitejs-vite-62wyd1?file=.test%2Fsome.js,index.html,package.json&terminal=dev
System Info
stackblitz, [email protected]
Used Package Manager
npm
Logs
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.