Patch #29359 » replace-mime-types-with-mini_mime-v2.diff
Gemfile (working copy) | ||
---|---|---|
7 | 7 |
gem "rails", "5.2.1" |
8 | 8 |
gem "coderay", "~> 1.1.1" |
9 | 9 |
gem "request_store", "1.0.5" |
10 |
gem "mime-types", "~> 3.0"
|
|
10 |
gem "mini_mime"
|
|
11 | 11 |
gem "actionpack-xml_parser" |
12 | 12 |
gem "roadie-rails", "~> 1.3.0" |
13 | 13 |
gem "roadie", "~> 3.2.1" |
lib/redmine/mime_type.rb (working copy) | ||
---|---|---|
62 | 62 |
# returns mime type for name or nil if unknown |
63 | 63 |
def self.of(name) |
64 | 64 |
return nil unless name.present? |
65 |
if m = name.to_s.match(/(^|\.)([^\.]+)$/)
|
|
66 |
extension = m[2].downcase
|
|
65 |
extension = File.extname(name)[1..-1]
|
|
66 |
if extension
|
|
67 | 67 |
@known_types ||= Hash.new do |h, ext| |
68 | 68 |
type = EXTENSIONS[ext] |
69 |
type ||= MIME::Types.type_for(ext).first.to_s.presence
|
|
69 |
type ||= MiniMime.lookup_by_filename("base.#{ext}").try(:content_type)
|
|
70 | 70 |
h[ext] = type |
71 | 71 |
end |
72 |
@known_types[extension] |
|
72 |
@known_types[extension.downcase]
|
|
73 | 73 |
end |
74 | 74 |
end |
75 | 75 |