Commit 13e0447 1 parent 0de33cd commit 13e0447 Copy full SHA for 13e0447
File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change
1
+ require "set"
2
+
1
3
module IRuby
2
4
module Display
3
5
class << self
@@ -50,14 +52,15 @@ def protect(mime, data)
50
52
ascii? ( mime ) ? data . to_s : [ data . to_s ] . pack ( 'm0' )
51
53
end
52
54
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
+
53
62
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 )
61
64
true
62
65
else
63
66
MIME ::Type . new ( mime ) . ascii?
You can’t perform that action at this time.
0 commit comments