29359-remove-known-types-hash-v2.patch

Go MAEDA, 2018-08-14 17:16

Download (1.14 KB)

View differences:

Gemfile
7 7
gem "rails", "5.2.1"
8 8
gem "coderay", "~> 1.1.1"
9 9
gem "request_store", "1.0.5"
10
gem "mini_mime", "~> 1.0"
10
gem "mini_mime", "~> 1.0.1"
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
59 59

  
60 60
    # returns mime type for name or nil if unknown
61 61
    def self.of(name)
62
      return nil unless name.present?
63
      extension = File.extname(name)[1..-1].to_s.downcase
64
      if extension.present?
65
        @known_types ||= Hash.new do |h, ext|
66
          type = EXTENSIONS[ext]
67
          type ||= MiniMime.lookup_by_filename("a.#{ext}").try(:content_type)
68
          h[ext] = type
69
        end
70
        @known_types[extension]
62
      ext = File.extname(name.to_s)[1..-1]
63
      if ext
64
        ext.downcase!
65
        EXTENSIONS[ext] ||
66
          ((mi = MiniMime.lookup_by_extension(ext)) && mi.content_type)
71 67
      end
72 68
    end
73 69