http-errors
http-errors copied to clipboard
fix: handle NaN status codes by defaulting to 500
Previously, when createError(NaN) was called, the status validation would fail to catch NaN because typeof NaN === 'number' is true in JavaScript. This resulted in errors with NaN status codes, which could cause issues in downstream code.
This fix adds an explicit isNaN() check to the status validation logic, ensuring that NaN status codes are properly caught and defaulted to 500.
Additionally, a test case has been added to verify this behavior and prevent regression.
I like it 👍
Thanks 😌