Skip to content

Commit

Permalink
Determine the MIME type for the icon path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Aug 15, 2024
1 parent 55f2b35 commit 93005e7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion glue_jupyter/common/toolbar_vuetify.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from mimetypes import guess_type
import os
import ipyvuetify as v
import traitlets
Expand Down Expand Up @@ -76,7 +77,11 @@ def add_tool(self, tool):
else:
path = icon_path(tool.icon, icon_format=ext)

format = "svg+xml" if ext == "svg" else ext
format = guess_type(path)[0]
image_prefix = "image/"
if format is None or not format.startswith(image_prefix):
raise ValueError(f"Invalid or unknown image MIME type for: {path}")

Check warning on line 83 in glue_jupyter/common/toolbar_vuetify.py

View check run for this annotation

Codecov / codecov/patch

glue_jupyter/common/toolbar_vuetify.py#L83

Added line #L83 was not covered by tests
format = format[len(image_prefix):]
self.tools_data = {
**self.tools_data,
tool.tool_id: {
Expand Down

0 comments on commit 93005e7

Please sign in to comment.