jshttp / negotiator

An HTTP content negotiator for Node.js
MIT License
309 stars 33 forks source link

Parameter names should be case insensitive #37

Closed ethanresnick closed 9 years ago

ethanresnick commented 9 years ago

This comes from RFC 7231, which says: "The type, subtype, and parameter name tokens are case-insensitive."

Code to reproduce the issue:

var request = {
  headers: {
    accept: 'text/html;Charset="utf-8'
  }
};

var Negotiator = require('negotiator');
var negotiator = Negotiator(request);
var availableMediaTypes = ['text/html;charset=utf-8'];

// Expected result below: 'text/html;charset=utf-8'
// Actual result: undefined
console.log(negotiator.mediaType(availableMediaTypes))
dougwilson commented 9 years ago

lol. Gosh darn it :) Eventually when the media part uses content-type module in the next major these issues won't happen any longer :D I appreciate the report immensely!

ethanresnick commented 9 years ago

Absolutely! I found this as I was digging through the RFCs to investigate #35. I'll leave a comment there soon with my findings, and open up other issues as they arise.

dougwilson commented 9 years ago

Alright, should be fixed now :)

dougwilson commented 9 years ago

Published to npm as 0.5.3