vite server: escape colon in path#6364
Conversation
|
Why is |
|
My quick guess is that during the prebundle scan, since But either way if we do want a quick fix, we should update flattenId to handle colons instead, but I don't think this is a sustainable change and fix the question above instead. |
| middlewares.use(function escapeColonMiddleware(req, res, next) { | ||
| if (req.url) { | ||
| // example url: /node_modules/.vite/node:stream.js?v=xxxxxxxx | ||
| req.url = req.url.replace(/:/g, '_') |
There was a problem hiding this comment.
This regex doesn't look safe at all 👀
Is it really wanted to find all colons? Also that one in query params?
Beside that, I think this would need a test
There was a problem hiding this comment.
if we want to do this, shouldn't it only happen for node:?
|
this is just a quick hack, obviously ...
not relevant, but if you want to reproduce, see #5398 (comment) the problem is the mismatch between
wdym? colon would break on windows, see valid filenames |
part of issue #5398 (comment)
module
node:streamis cached asnode_modules/.vite/node_stream.jsbut importing
node:streamreturns http 404 not foundsolution: rewrite the url path: escape colon to underscore
todo
replace only
/node_modules/.vite/xxxxpathsbut not
/@id/__vite-xxxxetctodo: test production mode
only tested in development mode (npx vite)
todo: maybe parse
req.urlto only replace the pathavoid false replacements like
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).