]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup: use safe navigation operator in lib/redmine/mime_type.rb
authorGo MAEDA <maeda@farend.jp>
Thu, 2 May 2019 07:08:19 +0000 (07:08 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 2 May 2019 07:08:19 +0000 (07:08 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@18116 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/mime_type.rb

index 5a00937d924e27b419ddd97bc62e9c51d8eae080..310aa119906f13453808a5ca193438e9eb4422a3 100644 (file)
@@ -64,21 +64,20 @@ module Redmine
       ext = File.extname(name.to_s)[1..-1]
       if ext
         ext.downcase!
-        EXTENSIONS[ext] ||
-          ((mi = MiniMime.lookup_by_extension(ext)) && mi.content_type)
+        EXTENSIONS[ext] || MiniMime.lookup_by_extension(ext)&.content_type
       end
     end
 
     # Returns the css class associated to
     # the mime type of name
     def self.css_class_of(name)
-      mime = of(name)
-      mime && mime.tr('/', '-')
+      mimetype = of(name)
+      mimetype&.tr('/', '-')
     end
 
     def self.main_mimetype_of(name)
       mimetype = of(name)
-      mimetype.split('/').first if mimetype
+      mimetype&.split('/')&.first
     end
 
     # return true if mime-type for name is type/*