Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
!isExcludedUrl(decodedUrl)
) {
const result = await processAssetUrl(
url,
decodedUrl,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLinkShouldInline(node, attr.attributes),
)
return result !== decodedUrl
Expand Down
8 changes: 8 additions & 0 deletions playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,14 @@ describe.runIf(isBuild)('encodeURI', () => {
const img = await page.$('.encodeURI')
expect(await img.getAttribute('src')).toMatch(/^data:image\/png;base64,/)
})

test('img srcset with encodeURI', async () => {
const img = await page.$('.encodeURI')
const srcset = await img.getAttribute('srcset')
srcset.split(', ').forEach((candidate) => {
expect(candidate).toMatch(/^data:image\/png;base64,\S+ \dx$/)
})
})
})

test('new URL(..., import.meta.url)', async () => {
Expand Down
4 changes: 4 additions & 0 deletions playground/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ <h2>encodeURI for the address</h2>
<img
class="encodeURI"
src="./nested/%E3%83%86%E3%82%B9%E3%83%88-%E6%B8%AC%E8%A9%A6-white%20space.png"
srcset="
./nested/%E3%83%86%E3%82%B9%E3%83%88-%E6%B8%AC%E8%A9%A6-white%20space.png 1x,
./nested/%E3%83%86%E3%82%B9%E3%83%88-%E6%B8%AC%E8%A9%A6-white%20space.png 2x
"
/>
</div>

Expand Down
Loading