Skip to content

Commit

Permalink
perf: single slash does not need to be replaced (#13980)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Jul 29, 2023
1 parent b9a8d65 commit 66f522c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/middlewares/static.ts
Expand Up @@ -101,7 +101,7 @@ export function serveStaticMiddleware(
return next()
}

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

// apply aliases to static requests as well
Expand Down Expand Up @@ -154,7 +154,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!.replace(/^\/+/, '/'), 'http://example.com')
const url = new URL(req.url!.replace(/^\/{2,}/, '/'), 'http://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 66f522c

Please sign in to comment.