You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the file bodyDecoder-middleware.js, lines 47-53, the server incorrectly handles Content-type: application/json; charset=utf-8 headers and similarly formatted headers for form data (application/x-www-form-urlencoded). The existing code uses strict string comparison, causing issues when the Content-type header contains additional properties like charset.
This code only works for requests that send a pure Content-type: application/json or Content-type: application/x-www-form-urlencoded without any additional properties like charset.
Expected behavior
The code should be able to handle Content-type headers with additional parameters.
Standard Practice According to MDN
According to MDN's documentation on Content-Type, the header can contain additional parameters (like charset), separated by a semicolon. Therefore, using startsWith would align better with this standard practice.
Solution
A possible solution is to change the string comparison to check if the Content-type starts with the desired value. Below is the proposed change:
Description
In the file
bodyDecoder-middleware.js
, lines 47-53, the server incorrectly handlesContent-type: application/json; charset=utf-8
headers and similarly formatted headers for form data (application/x-www-form-urlencoded
). The existing code uses strict string comparison, causing issues when the Content-type header contains additional properties like charset.Existing Code
This code only works for requests that send a pure
Content-type: application/json
orContent-type: application/x-www-form-urlencoded
without any additional properties like charset.Expected behavior
The code should be able to handle
Content-type
headers with additional parameters.Standard Practice According to MDN
According to MDN's documentation on Content-Type, the header can contain additional parameters (like charset), separated by a semicolon. Therefore, using
startsWith
would align better with this standard practice.Solution
A possible solution is to change the string comparison to check if the Content-type starts with the desired value. Below is the proposed change:
Steps to Reproduce
Content-type: application/json; charset=utf-8
header and JSON payload.Thank you for taking the time to look into this issue.
The text was updated successfully, but these errors were encountered: