express
express copied to clipboard
fix(res): throw error when res.redirect(undefined) is called
Calling res.redirect(undefined) currently sends a 302 response with Location: undefined,
resulting in an invalid redirect header.
This PR throws a TypeError when the URL argument is missing, consistent with the deprecation warning ("Provide a url argument") and prevents malformed headers.
Improved the redirect tests to match Express behavior more accurately:
- correct expected error message
- unified jsonError handler
- stronger Location header assertion
- stack presence check
The updated test suite does not change redirect behavior, but validates it more accurately and prevents future regressions. Fixes #6941