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: replace parse with splitFileAndPostfix #18185

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: use new URL second argument
  • Loading branch information
btea committed Sep 25, 2024
commit b4eff27c48a768fc805a8061a21dded7736ae96e
3 changes: 1 addition & 2 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@ async function fileToBuiltUrl(
// emit as asset
// On Mac or Linux platforms, the path resolution is considered an invalid URL by the new URL and an error will be thrown.
// So it will be converted into a valid URL.
const validUrl = 'http://example.com/' + id.split('/').slice(-1)[0]
let { search, hash } = new URL(validUrl)
let { search, hash } = new URL(id, 'http://example.com')
if (!search && id.includes('?')) {
// When the string structure is like `woff2?#iefix`, the search value obtained by parsing the new URL is an empty string
search = '?'
Expand Down