-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle encoded base paths #17577
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is largely a copy of the other test files.
/ecosystem-ci run |
Should we have a internal |
📝 Ran ecosystem CI on
✅ histoire, ladle, laravel, marko, previewjs, quasar, qwik, rakkas, remix, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress |
/ecosystem-ci run analogjs |
📝 Ran ecosystem CI on
✅ |
I was wondering that in the PR description too. I think I can refactor to that if we think it's cleaner. Also, looks like I need to investigate the analog fail (or seems like they recently merged something) |
When running the playground, I'm seeing two $ pnpm -C playground/assets dev:encoded-base
...
VITE v5.3.5 ready in 94 ms
➜ Local: http://localhost:9524/foo%20bar/
➜ Network: use --host to expose
➜ press h + enter to show help
6:46:19 PM [vite] Pre-transform error: No matching HTML proxy module found from /foo bar/index.html?html-proxy&index=4.js
6:46:19 PM [vite] Pre-transform error: Failed to load url /foo bar/asset/main.js (resolved id: /foo bar/asset/main.js). Does the file exist? |
I just pushed a fix to handle them. Looks like we were passing urls with decoded base, and then trying to strip with an encoded base, causing I'm not particularly happy with my fix as encoded and decoded urls/base are slightly more intertwined, but I think it's probably sufficient for now. |
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ analogjs, histoire, ladle, laravel, marko, previewjs, quasar, rakkas, remix, sveltekit, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress |
Description
supersedes and closes #16412
Due to the changes from #15311 (and tweaks thereafter) (Vite 5.2), I believe it broke most cases of
base
that contains encoded base paths, e.g./foo%20bar/
, which Vite encodes internally even if you pass/foo bar/
.I'm somewhat relieved that we didn't get a lot of reports of this, because
base
paths that look like this are hard 🥲Because
resolvedConfig.base
is a URL-encoded string, when we merge it with some un-encoded strings, and encode the merged string, thebase
portion will get double encoded. The solution in this PR is to decode thebase
first.In the future, maybe we can revisit if we want to have
resolvedConfig.base
be decoded only, or introduce a newresolvedConfig.decodedBase
? Or we can say we don't support strange base paths.NOTE: I also updated the code in
plugin-legacy
together as I noticed it while searching the codebase.