Skip to content

Commit

Permalink
fix(node): update call stripBase in utils.ts before passing to fsPath…
Browse files Browse the repository at this point in the history
…FromUrl (fix vitejs#9438)
  • Loading branch information
xinxinhe1810 committed Jul 4, 2023
1 parent 2b1ffe8 commit fa92a74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
}
}

// record as safe modules
server?.moduleGraph.safeModulesPath.add(fsPathFromUrl(url))
// record as safe modules # stripBase: https://github.com/vitejs/vite/issues/9438#issuecomment-1486662486
server?.moduleGraph.safeModulesPath.add(
fsPathFromUrl(stripBase(url, base)),
)

if (url !== specifier) {
let rewriteDone = false
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/middlewares/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
removeLeadingSlash,
shouldServeFile,
slash,
stripBase,
} from '../../utils'

const knownJavascriptExtensionRE = /\.[tj]sx?$/
Expand Down Expand Up @@ -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))

if (server._fsDenyGlob(file)) return false

Expand Down

0 comments on commit fa92a74

Please sign in to comment.