diff options
author | Go MAEDA <maeda@farend.jp> | 2019-05-02 07:08:19 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-05-02 07:08:19 +0000 |
commit | 815f4f2d9429ff128b04e1fb9d55476fbb11048d (patch) | |
tree | 49b1b8093de5c61762f988dd17905a798294faf7 /lib | |
parent | fc8bc763620cfb5dcde5590302ee04d9c5ee5859 (diff) | |
download | redmine-815f4f2d9429ff128b04e1fb9d55476fbb11048d.tar.gz redmine-815f4f2d9429ff128b04e1fb9d55476fbb11048d.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/mime_type.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/redmine/mime_type.rb b/lib/redmine/mime_type.rb index 5a00937d9..310aa1199 100644 --- a/lib/redmine/mime_type.rb +++ b/lib/redmine/mime_type.rb @@ -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/* |