Skip to content

feat(image): [image] The image component supports base64 in svg format #2858

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion packages/renderless/src/image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const mounted =
}

export const filterImageUrl = (props) => () => {
const isBase64 = /^data:(image|application)\/(png|jpg|jpeg|gif|octet-stream);base64,([a-zA-Z0-9+/]+={0,2})/
const isBase64 = /^data:(image|application)\/(png|jpg|jpeg|gif|octet-stream|svg\+xml);base64,([a-zA-Z0-9+/]+={0,2})/

Choose a reason for hiding this comment

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

The regular expression has been updated to include svg+xml in the list of supported base64 image types. This change allows the component to correctly identify and process base64 encoded SVG images.


return isBase64.test(props.src) ? props.src : xss.filterUrl(props.src)
}
Loading