Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why mime.getType('unknown') returns null rather then 'application/octet-stream' #195

Closed
xxoo opened this issue Mar 1, 2018 · 2 comments
Closed

Comments

@xxoo
Copy link

xxoo commented Mar 1, 2018

according to https://tools.ietf.org/html/rfc2045

Any entity with an unrecognized Content-Transfer-Encoding must be
treated as if it has a Content-Type of "application/octet-stream",
regardless of what the Content-Type header field actually says.

as i understood a unknown file type should use application/octet-stream for sure.

@broofa
Copy link
Owner

broofa commented Mar 1, 2018

This module is not an RFC-related module. It's a thin, optimized API for the mime-db dataset. That said, the previous version of this module had the behavior you described. However, this behavior was deemed undesirable (see #139).

Basically, returning null is what most people expect, and it's trivial for callers of this API to code a default value. E.g. var type = mime.getType(...) || 'application/octet-stream';.

@broofa broofa closed this as completed Mar 1, 2018
@almercier
Copy link

almercier commented Aug 9, 2019

@broofa This should have been documented as a breaking change as this broke our logic what was expecting the 'application/octet-stream' default return value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants