Skip to content

Commit 7d8100a

Browse files
authored
fix: port #13348 to v2, fs.deny with leading double slash (#13350)
1 parent 4f00f58 commit 7d8100a

File tree

1 file changed

+2
-2
lines changed
  • packages/vite/src/node/server/middlewares

1 file changed

+2
-2
lines changed

packages/vite/src/node/server/middlewares/static.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function serveStaticMiddleware(
7878
return next()
7979
}
8080

81-
const url = new URL(req.url!, 'http://example.com')
81+
const url = new URL(req.url!.replace(/^\/+/, '/'), 'http://example.com')
8282
const pathname = decodeURIComponent(url.pathname)
8383

8484
// apply aliases to static requests as well
@@ -125,7 +125,7 @@ export function serveRawFsMiddleware(
125125

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

0 commit comments

Comments
 (0)