`Accept-Language` in different casing
caridy opened this issue · comments
Caridy Patiño commented
We have noticed that some browsers will send the Accept-Language
header all in lower case (e.g.: fr-fr), some others will send it as fr-FR
. This put a borden on the user to deal with these differences when it could be done at the lower level. Here is a repro case using npm REPL:
var n = require('negotiator/lib/language');
undefined
> n('en-GB', ['en-US', 'en-GB', 'fr-FR'])
[ 'en-GB' ]
> n('en-US', ['en-US', 'en-GB', 'fr-FR'])
[ 'en-US' ]
> n('en-us', ['en-US', 'en-GB', 'fr-FR'])
[] // FAILS
> n('en-gb', ['en-US', 'en-GB', 'fr-FR'])
[] // FAILS
what is the recommendation to solve this problem? can this be covered by negotiator/lib/language
directly?
/cc @ericf
Federico Romero commented
I think negotiator should handle this. I can write a fix for this over the weekend.
Douglas Wilson commented
I checked and verified that RFC 4647 (via RFC 7231) does indeed say comparisons are to me made case-insensitive, just as a point of reference :)
Caridy Patiño commented
awesome, thanks you guys!