jshttp / type-is

Infer the content-type of a request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AdonisJS broke for the normalizeType change

wiliame opened this issue · comments

Hi, adonisjs is broken because of a change in this library.

The commit change is the next one:
3c1d9b7#diff-168726dbe96b3ce427e7fedce31bb0bc

You have forced the type of the argument to be "string" but node-req, the library that is using adonisjs calls "is" with the request (object) and not with the content-type (string):

I don't know why they calls the function with the request and node-req github page dissapeared to report them

https://github.com/poppinss/node-req/issues

The method tryNormalizeType works fine with "request objects", but forcing the argument to be a string breaks node-req and adonisjs, it's possible to remove the type force until I report the issue to AdonisJS?

Thanks!

Thanks for the report. This should not have broken, maybe our test suite is missing a test. I read though your description, but was not able to reproduce. Would you be able to provide code I can run that demonstrates the issue?

Basically, nothing was intended to be broken. I'm sorry it did. I could simply revert the commit, but that will never help this from happening again since there will be no test case for whatever the issue is. And perhaps a full revert isn't needed to fix it, not sure without a repo.

I tried to pass an object to typeis.is in the old version and it returns false just like in the new version being published:

$ node -e 'console.log(require("type-is/package").version);console.dir(require("type-is").is({},["json"]))'
1.6.16
false

and

$ node -e 'console.log(require("type-is/package").version);console.dir(require("type-is").is({},["json"]))'
1.6.17
false

Though an object can have all sorts of properties, perhaps what does the object look like?

Ok, I figure it out: it was some undocumented and untested thing. IN the future, please provide a clear reproduction case with your reports for a quicker resolution.

Published as 1.6.18