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

refactor: delete unused try catch #4638

Merged
merged 1 commit into from
Aug 17, 2021
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
19 changes: 4 additions & 15 deletions packages/vite/src/node/server/middlewares/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,10 @@ export function transformMiddleware(
return
}

let url: string
try {
url = removeTimestampQuery(req.url!).replace(NULL_BYTE_PLACEHOLDER, '\0')
} catch (err) {
// if it starts with %PUBLIC%, someone's migrating from something
// like create-react-app
let errorMessage: string
if (req.url?.startsWith('/%PUBLIC')) {
errorMessage = `index.html shouldn't include environment variables like %PUBLIC_URL%, see https://vitejs.dev/guide/#index-html-and-project-root for more information`
} else {
errorMessage = `Vite encountered a suspiciously malformed request ${req.url}`
}
next(new Error(errorMessage))
return
}
let url = removeTimestampQuery(req.url!).replace(
NULL_BYTE_PLACEHOLDER,
'\0'
)

const withoutQuery = cleanUrl(url)

Expand Down