mirror of
https://github.com/redmine/redmine.git
synced 2025-12-17 22:10:27 +01:00
Refactor Redmine::MimeType.of. Uses MiniMime.lookup_by_extension instead of lookup_by_filename (#29359).
git-svn-id: http://svn.redmine.org/redmine/trunk@17473 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -7,7 +7,7 @@ end
|
||||
gem "rails", "5.2.1"
|
||||
gem "coderay", "~> 1.1.1"
|
||||
gem "request_store", "1.0.5"
|
||||
gem "mini_mime", "~> 1.0"
|
||||
gem "mini_mime", "~> 1.0.1"
|
||||
gem "actionpack-xml_parser"
|
||||
gem "roadie-rails", "~> 1.3.0"
|
||||
gem "roadie", "~> 3.2.1"
|
||||
|
||||
@@ -59,15 +59,11 @@ module Redmine
|
||||
|
||||
# returns mime type for name or nil if unknown
|
||||
def self.of(name)
|
||||
return nil unless name.present?
|
||||
extension = File.extname(name)[1..-1].to_s.downcase
|
||||
if extension.present?
|
||||
@known_types ||= Hash.new do |h, ext|
|
||||
type = EXTENSIONS[ext]
|
||||
type ||= MiniMime.lookup_by_filename("a.#{ext}").try(:content_type)
|
||||
h[ext] = type
|
||||
end
|
||||
@known_types[extension]
|
||||
ext = File.extname(name.to_s)[1..-1]
|
||||
if ext
|
||||
ext.downcase!
|
||||
EXTENSIONS[ext] ||
|
||||
((mi = MiniMime.lookup_by_extension(ext)) && mi.content_type)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user