Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: single slash does not need to be replaced #13980

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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