Skip to content

Documentation bug in request.acceptsLanguages #1401

@dotnetCarpenter

Description

@dotnetCarpenter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions