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

mime lookup for application/json returns false #32

Closed
pcgilday opened this issue Mar 15, 2017 · 5 comments
Closed

mime lookup for application/json returns false #32

pcgilday opened this issue Mar 15, 2017 · 5 comments
Assignees
Labels

Comments

@pcgilday
Copy link

Passing "application/json" to the mime.lookup returns false. I am assuming this is a bug and that passing a valid mime-type to mime.lookup should return that same mime-type. Also, the README says this behaves similarly to the mime module which handles this type the way I would expect. Examples below.

Using mime-types

12:33 $ node
> const mime = require('mime-types')
> mime.lookup('application/json')
false
> mime.lookup('json')
'application/json'
>

Using mime

12:38 $ node
> const mime = require('mime')
> mime.lookup('application/json')
'application/json'
> mime.lookup('json')
'application/json'
>

If this is the intended behavior, then it should probably be mentioned as a difference between this and the mime package (along with the other differences called out) in the README.

Happy to help out with a PR if this is indeed a bug and not the intended behavior

@dougwilson
Copy link
Contributor

dougwilson commented Mar 15, 2017

You're encountering a bug in mime itself. You see, you're passing in application/json and that module incorrectly thing you're looking for the file json and then incorrectly things the file extension for that is json. You can see it's not echoing the type if you do

$ node
> const mime = require('mime')
> mime.lookup('text/plain')
'application/octet-stream'
>

@dougwilson
Copy link
Contributor

This is the bug: broofa/mime#113

@dougwilson
Copy link
Contributor

And this module fixed the bug (which is one of the purposes of this module: incorporate bug fixes that mime is not fixing :) ).

@dougwilson dougwilson self-assigned this Mar 15, 2017
dougwilson added a commit that referenced this issue Mar 20, 2017
@dougwilson
Copy link
Contributor

I updated the blurb in the README to note that there are bug fixes to the .lookup method compared to the mime module.

@pcgilday
Copy link
Author

Thank you for clarifying, I misunderstood the use case for the lookup function initially.

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

No branches or pull requests

2 participants