Skip to content

Commit

Permalink
Fix svg mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
e10v committed Jun 15, 2023
1 parent e676086 commit f89d42d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/rico/_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ def __init__(
data = data.encode()
encoded_image = base64.b64encode(data).decode()

if format == "svg":
format = "svg+xml" # noqa: A001

element = ET.Element(
"img",
attrib={"src": f"data:image/{format};base64,{encoded_image}"},
Expand Down
2 changes: 1 addition & 1 deletion tests/test__content.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_image_svg(data: str | bytes):
img = tuple(div)[0]
assert isinstance(img, ET.Element)
assert img.tag == "img"
assert img.attrib == {"src": f"data:image/svg;base64,{encoded_image}"}
assert img.attrib == {"src": f"data:image/svg+xml;base64,{encoded_image}"}
assert img.text is None
assert img.tail is None
assert len(img) == 0
Expand Down

0 comments on commit f89d42d

Please sign in to comment.