Skip to content

Commit

Permalink
fix: filter out empty srcset (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Apr 6, 2021
1 parent 0dc6e37 commit fe0e754
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,16 @@ export async function processSrcSet(
srcs: string,
replacer: (arg: ImageCandidate) => Promise<string>
) {
const imageCandidates: ImageCandidate[] = srcs.split(',').map((s) => {
const [url, descriptor] = s
.replace(escapedSpaceCharacters, ' ')
.trim()
.split(' ', 2)
return { url, descriptor }
})
const imageCandidates: ImageCandidate[] = srcs
.split(',')
.map((s) => {
const [url, descriptor] = s
.replace(escapedSpaceCharacters, ' ')
.trim()
.split(' ', 2)
return { url, descriptor }
})
.filter(({ url, descriptor }) => url && descriptor)

const ret = await Promise.all(
imageCandidates.map(async ({ url, descriptor }) => {
Expand Down

0 comments on commit fe0e754

Please sign in to comment.