discourse / mini_mime

minimal mime type library
MIT License
95 stars 34 forks source link

Binary differences between mini_mime and mime-types #22

Closed gmcgibbon closed 5 years ago

gmcgibbon commented 5 years ago

👋 I'm converting some code to use mini_mime instead of mime-types and I noticed a strange inconsistency in how types are labelled as binary. Here's the difference:

In mime-types: MIME::Types.of("a.css").first.binary? #=> false In mini_mime: MiniMime.lookup_by_filename("a.css").binary? #> true

This also happens with all other types that are labelled as 8bit encoding in the db file. I think this line might be wrong.

Side note: it might also be cool to add a #ascii? method to check for non-binary encodings.

jeremy commented 5 years ago

mime-types uses the same logic to classify binary?/ascii? network transfer encoding; curious that these differ. Which MIME type does MIME::Types.of("a.css").first return?

(The method names are confusing here. This isn't indicating that the type itself is binary/ascii, but whether the type needs transfer encoding for non-8-bit-clean channels, such as attaching to an email message.)

gmcgibbon commented 5 years ago

I see. This is my mistake. I'm using an ancient version of mime-types that does this. Many thanks for your help. 🙏