Class: RestMan::Request::MaybeConvertExtension
- Inherits:
-
ActiveMethod::Base
- Object
- ActiveMethod::Base
- RestMan::Request::MaybeConvertExtension
- Defined in:
- lib/restman/request/maybe_convert_extension.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/restman/request/maybe_convert_extension.rb', line 7 def call unless ext =~ /\A[a-zA-Z0-9_@-]+\z/ # Don't look up strings unless they look like they could be a file # extension known to mime-types. # # There currently isn't any API public way to look up extensions # directly out of MIME::Types, but the type_for() method only strips # off after a period anyway. return ext end types = MIME::Types.type_for(ext) if types.empty? ext else types.first.content_type end end |