mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-31 20:59:38 +00:00
Code cleanup: use safe navigation operator in lib/redmine/mime_type.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@18116 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fc8bc76362
commit
815f4f2d94
@ -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/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user