Skip to content

Commit 66f522c

Browse files
authoredJul 29, 2023
perf: single slash does not need to be replaced (#13980)
1 parent b9a8d65 commit 66f522c

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
@@ -101,7 +101,7 @@ export function serveStaticMiddleware(
101101
return next()
102102
}
103103

104-
const url = new URL(req.url!.replace(/^\/+/, '/'), 'http://example.com')
104+
const url = new URL(req.url!.replace(/^\/{2,}/, '/'), 'http://example.com')
105105
const pathname = decodeURI(url.pathname)
106106

107107
// apply aliases to static requests as well
@@ -154,7 +154,7 @@ export function serveRawFsMiddleware(
154154

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

0 commit comments

Comments
 (0)
Please sign in to comment.