Skip to content

Commit

Permalink
refactor: delete unused try catch (#4638)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Aug 17, 2021
1 parent 633c03a commit ad71494
Showing 1 changed file with 4 additions and 15 deletions.
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

0 comments on commit ad71494

Please sign in to comment.