-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
🐛 bugDefect / BugDefect / Bug⌛ staleWill soon be closed by stalebot unless there is activityWill soon be closed by stalebot unless there is activity
Description
The "unless" condition here could be improved in distingushing whether src is a path to image or is an encoded data object
def embed(src, mime_type, label)
case(mime_type)
when /^image\/(png|gif|jpg|jpeg)/
unless File.file?(src) or src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/
type = mime_type =~ /;base[0-9]+$/ ? mime_type : mime_type + ";base64"
src = "data:" + type + "," + src
end
embed_image(src, label)
Problem:
In my case, src is a relative path to the screenshot file, so File.file?(src) ran in the context of the file where html formatter is defined - will return false. This leads to the following src of image in the html report. Thus, image is not found in the report.
src="data:image/png;base64,screenshots/my_screenshot.png"
Metadata
Metadata
Assignees
Labels
🐛 bugDefect / BugDefect / Bug⌛ staleWill soon be closed by stalebot unless there is activityWill soon be closed by stalebot unless there is activity