docs: fix JSDoc for req.accepts() return value and parameter format#6936
Merged
bjohansebas merged 6 commits intoexpressjs:masterfrom Jan 16, 2026
Merged
Conversation
This was referenced Dec 2, 2025
Contributor
|
Could you also update the return value here? It should be Lines 112 to 115 in 2d0884f |
Contributor
|
The example with Lines 107 to 108 in 2d0884f |
Contributor
Author
|
@krzysdz Done :) |
bjohansebas
approved these changes
Jan 16, 2026
| * req.accepts('text/html'); | ||
| * // => "text/html" | ||
| * req.accepts('json, text'); | ||
| * req.accepts('json', 'text'); |
Member
There was a problem hiding this comment.
I was looking for how long we haven't had that support; it happened in cec0c06, for https://github.com/expressjs/express/releases/tag/4.0.0-rc1.
Member
There was a problem hiding this comment.
That is, that support didn’t come when the accepts package was created.
krzysdz
added a commit
to krzysdz/accepts
that referenced
this pull request
Jan 18, 2026
Port changes from expressjs/express#6936 and expressjs/express#2527.
krzysdz
added a commit
to krzysdz/accepts
that referenced
this pull request
Jan 18, 2026
Port changes from expressjs/express#6936 and expressjs/express#2527. Co-Authored-By: Marcos Molina <53741892+marcosmol204@users.noreply.github.com> Co-Authored-By: Elvin Yung <elvin@elvinyung.com>
jonchurch
pushed a commit
to krzysdz/accepts
that referenced
this pull request
Jan 20, 2026
Port changes from expressjs/express#6936 and expressjs/express#2527. Co-Authored-By: Marcos Molina <53741892+marcosmol204@users.noreply.github.com> Co-Authored-By: Elvin Yung <elvin@elvinyung.com>
jonchurch
pushed a commit
to jshttp/accepts
that referenced
this pull request
Jan 20, 2026
Port changes from expressjs/express#6936 and expressjs/express#2527. Co-authored-by: krzysdz <krzysdz@users.noreply.github.com> Co-authored-by: Marcos Molina <53741892+marcosmol204@users.noreply.github.com> Co-authored-by: Elvin Yung <elvin@elvinyung.com>
kylewilliams60
added a commit
to kylewilliams60/https-accepts
that referenced
this pull request
Feb 11, 2026
Port changes from expressjs/express#6936 and expressjs/express#2527. Co-authored-by: krzysdz <krzysdz@users.noreply.github.com> Co-authored-by: Marcos Molina <53741892+marcosmol204@users.noreply.github.com> Co-authored-by: Elvin Yung <elvin@elvinyung.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Incorrect return value
The existing JSDoc states that the method returns
undefinedwhen no acceptable type is found.In reality, the underlying negotiation package returns
false, and that is what Express exposes.Supporting code (from the underlying
acceptspackage):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):
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.