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 returnsnil
when no matches were found: https://github.com/mime-types/ruby-mime-types/blob/8de8dbb6ed312e33a746282757a9af50cb0cbc0d/lib/mime/types.rb#L216-L220 to be more specific:nil
value then gets assigned tomatches
variable: https://github.com/mime-types/ruby-mime-types/blob/8de8dbb6ed312e33a746282757a9af50cb0cbc0d/lib/mime/types.rb#L123-L134 thenmatches
gets passed toprune_matches
function, that would also returnnil
ifmatches
parameter is set tonil
: https://github.com/mime-types/ruby-mime-types/blob/8de8dbb6ed312e33a746282757a9af50cb0cbc0d/lib/mime/types.rb#L210-L214 asort
function is called on the returnednil
, producing the error here: https://github.com/mime-types/ruby-mime-types/blob/8de8dbb6ed312e33a746282757a9af50cb0cbc0d/lib/mime/types.rb#L132