Skip to content

Commit

Permalink
fix: port #13348 to v2, fs.deny with leading double slash (#13350)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored May 26, 2023
1 parent 4f00f58 commit 7d8100a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/middlewares/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function serveStaticMiddleware(
return next()
}

const url = new URL(req.url!, 'https://example.com')
const url = new URL(req.url!.replace(/^\/+/, '/'), 'https://example.com')
const pathname = decodeURIComponent(url.pathname)

// apply aliases to static requests as well
Expand Down Expand Up @@ -125,7 +125,7 @@ export function serveRawFsMiddleware(

// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
return function viteServeRawFsMiddleware(req, res, next) {
const url = new URL(req.url!, 'https://example.com')
const url = new URL(req.url!.replace(/^\/+/, '/'), 'https://example.com')
// In some cases (e.g. linked monorepos) files outside of root will
// reference assets that are also out of served root. In such cases
// the paths are rewritten to `/@fs/` prefixed paths and must be served by
Expand Down

0 comments on commit 7d8100a

Please sign in to comment.