-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Accept-Language not interpreted correctly #46
Conversation
I agree it looks like a bug :) I'll check out that this matched the specs and then try to get a fix out very soon :) |
Basically, either that header is just non-sense (aka it seems like you are expecting that both |
I'm' very sorry, but this is not a bug in this module. The specification does describe the matching to use, and we do follow it in this case. (RFC 7231, which links to the algos in RFC 4647). Here is how it breaks down in your example: Given by the user agent: The algorithm describes matching against the ranges in order, from the most specific to the least specific (which means
The Apache |
@dougwilson thank you for looking into it. Can you explain that:
I don't see why a match to en should rate en-GB at quality 1 |
I'm not sure how I can explain it differently from what UI wrote above. Is the confusion at what step 5 does? |
I'd expect the "supported" languages on the server [en-US, en-GB] to be matched against the accepts header, and given there is en-US in the accepts header that it would be preferred. |
I understand that your expectation is different from what is set out in the specifications set forth to perform the matching in RFC 4647. Unfortunately you have stumbled into a module that has been created yo match the standards, rather than cater to everyone's different expeditions. I suggest perhaps using a different module that more closely aligns to your expectations and deviates from the standards. |
Thanks for your quick answers and investigation @dougwilson |
I just created a pr that illustrates what I see when trying to find the language from the accepts-language header. According to the docs,
languages
should return the best fit, and I am seeing unexpected behavior when I send in headers with values such asen,en-US;q=0.8
which is standard US browser header value in Chrome.If I call
language(['en-US', 'en-GB'])
I would expect the result to be en-US as that is an acceptable language that the server supports. The result is instead en-GB, leading me to believe there is a bug.