In the documentation (express 4.x) for req.acceptsLanguages, it states that:
Returns the first accepted language of the specified languages, based on the request’s Accept-Language HTTP header field. If none of the specified languages is accepted, returns false.
However, the code path delegates this call to jshttp/accepts which returns all requested languages from the Accept-Language HTTP header field.
We currently depend on this behavior to get the client's first language (we of course guard against * and missing header) from a request.
It appears to be equivalent for version 5.x: https://github.com/expressjs/express/blob/5.x/lib/request.js#L174
Can we please correct the documentation? I'm also afraid that this could break our use-case in the future, since returning false if no language argument is supplied will break our implementation.
PS. We can currently handle an empty array but not false. Using express 4.18.2
In the documentation (express 4.x) for
req.acceptsLanguages, it states that:However, the code path delegates this call to jshttp/accepts which returns all requested languages from the
Accept-LanguageHTTP header field.We currently depend on this behavior to get the client's first language (we of course guard against
*and missing header) from a request.It appears to be equivalent for version 5.x: https://github.com/expressjs/express/blob/5.x/lib/request.js#L174
Can we please correct the documentation? I'm also afraid that this could break our use-case in the future, since returning
falseif nolanguageargument is supplied will break our implementation.PS. We can currently handle an empty array but not
false. Using express 4.18.2