Method: Scrivito::Link#file_extension
- Defined in:
- app/cms/scrivito/link.rb
#file_extension ⇒ Object
Returns the file extension (e.g. zip, pdf) of the (internal or external) destination of this link. Returns an empty string if the file extension cannot be determined.
127 128 129 130 131 132 133 134 |
# File 'app/cms/scrivito/link.rb', line 127 def file_extension if internal? obj ? obj.file_extension : "" else path = URI.parse(url).path rescue nil path.blank? ? "" : File.extname(path)[1..-1] || "" end end |