MIME::Types[/regex/]: Exception thrown for unmatched regex
TheDeepestSpace opened this issue · 2 comments
TheDeepestSpace commented
MIME::Types[/regex_that_wont_match/]
=> NoMethodError: undefined method `sort' for nil:NilClass
from /var/lib/gems/2.3.0/gems/mime-types-3.1/lib/mime/types.rb:132:in `[]'
from /var/lib/gems/2.3.0/gems/mime-types-3.1/lib/mime/types/registry.rb:13:in `[]'
...
looks like match
function returns nil
when no matches were found:
ruby-mime-types/lib/mime/types.rb
Lines 216 to 220 in 8de8dbb
to be more specific:
[].inject(:+)
=> nil
nil
value then gets assigned to matches
variable:
ruby-mime-types/lib/mime/types.rb
Lines 123 to 134 in 8de8dbb
then
matches
gets passed to prune_matches
function, that would also return nil
if matches
parameter is set to nil
: ruby-mime-types/lib/mime/types.rb
Lines 210 to 214 in 8de8dbb
a
sort
function is called on the returned nil
, producing the error here: ruby-mime-types/lib/mime/types.rb
Line 132 in 8de8dbb
halostatue commented
halostatue commented
Resolved with edf3cd7.