MIME::Types
可以将 txt
识别为 text/plain
require 'mime/types'
MIME::Types.type_for("txt").first.to_s # => "text/plain"
我希望它默认也可以为
标签
执行相同的操作,但是现在它还不能。MIME::Types.type_for("tab").first.to_s # => ""
那么,鉴于以下情况:
MIME::Types['text/plain'].first.extensions
["txt", "asc", "c", "cc", "h", "hh", "cpp", "hpp", "dat", "hlp"]
是什么意思?为什么下面的代码不起作用:
MIME::Types['text/plain'].first.extensions.push("tab")
MIME::Types.type_for("tab").first.to_s # => still just ""