Skip to content

Conversation

@marcosmol204
Copy link

Description

This pull request updates the JSDoc for req.accepts() to correct two inaccuracies in the current documentation. These updates align the JSDoc with the behavior of the underlying npm package used by Express for content negotiation.

What This PR Fixes

  1. Incorrect return value
    The existing JSDoc states that the method returns undefined when no acceptable type is found.
    In reality, the underlying negotiation package returns false, and that is what Express exposes.

    Supporting code (from the underlying accepts package):

    // returns the best match or false
    return type || false
  2. Comma-separated values are not supported
    Some examples suggested that a comma-separated string (e.g., "json, text") is treated as multiple types.
    The npm package does not parse comma-separated strings.
    Only arrays or multiple arguments are supported.

    Supporting code (from the same package):

     if (!Array.isArray(types)) {
       types = new Array(arguments.length);
       for (var i = 0; i < types.length; i++) {
         types[i] = arguments[i];
       }
     }

This shows that each argument is captured individually, and values are not split on commas.

Why This Matters

The old JSDoc can mislead developers when debugging Accept header behavior or relying on inline IntelliSense.
This PR corrects the documentation so it accurately reflects the behavior of the npm module Express depends on.

Disclaimer

The incorrect assumptions present in the old JSDoc also exist in the underlying npm package.
This PR updates only the Express documentation and does not modify or fix the dependency itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant