vite icon indicating copy to clipboard operation
vite copied to clipboard

Invalid script path rewrite when folder starts with dot

Open gluck opened this issue 1 year ago • 0 comments

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)

image

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

gluck avatar Jul 25 '22 09:07 gluck