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(importAnalysis): strip url base before passing as safeModulePaths #13712
Changes from 2 commits
fa92a74
4fcfcf4
7dd7d4c
f9831af
1cc1ef8
aaf7799
eb81f16
5bb2605
d075dff
4556271
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
removeLeadingSlash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shouldServeFile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
slash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stripBase, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} from '../../utils' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const knownJavascriptExtensionRE = /\.[tj]sx?$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -194,7 +195,8 @@ export function isFileServingAllowed( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
): boolean { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!server.config.server.fs.strict) return true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const file = fsPathFromUrl(url) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// stripBase: https://github.com/vitejs/vite/issues/9438#issuecomment-1486662486 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const file = fsPathFromUrl(stripBase(url, server.config.rawBase)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is called from vite/packages/vite/src/node/server/index.ts Lines 614 to 646 in 1292ad0
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that's how it is. I remove stripBase here |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (server._fsDenyGlob(file)) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
it we're going to link to a comment it should probably be #9438 (comment), but it'd be nicer to just explain why it's necessary here rather than making someone copy paste a URL into their browser to read the explanation (same below)
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.
I tried to fix it. Thanks for guiding me on this PR.