jshttp / type-is

Infer the content-type of a request.
MIT License
226 stars 32 forks source link

`is(req, 'xml')` should be true when content-type is `text/xml` #24

Open creeperyang opened 8 years ago

creeperyang commented 8 years ago

When I use koa and its this.is('xml'), it makes me confused:

// content-type: 'text/xml'
this.is('xml') // false

I think application/xml and text/xml are both valid xml type.

dougwilson commented 8 years ago

Hi @creeperyang, yes, I agree. The weird discrepancy comes from how everything got bundled together: when you specify a file extension, instead of doing what seems more logical, and what you wait, and check for every possible media type that could represent that file extension, it instead only matches the primary media type for that extension.

The issue #15 is pretty much exactly the same issue, just for a different type.