fixed request accept jsdoc #6936
Open
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.