File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1+ require "set"
2+
13module IRuby
24 module Display
35 class << self
@@ -50,14 +52,15 @@ def protect(mime, data)
5052 ascii? ( mime ) ? data . to_s : [ data . to_s ] . pack ( 'm0' )
5153 end
5254
55+ # Each of the following mime types must be a text type,
56+ # but mime-types library tells us it is a non-text type.
57+ FORCE_ASCII_TYPES = Set [
58+ "application/javascript" ,
59+ "image/svg+xml"
60+ ] . freeze
61+
5362 def ascii? ( mime )
54- case mime
55- when "application/javascript"
56- # Special case for application/javascript.
57- # This needs because mime-types tells us application/javascript a non-text type.
58- true
59- when "image/svg+xml"
60- # mime-types tells us image/svg+xml a non-text type.
63+ if FORCE_ASCII_TYPES . include? ( mime )
6164 true
6265 else
6366 MIME ::Type . new ( mime ) . ascii?
You can’t perform that action at this time.
0 commit comments