express icon indicating copy to clipboard operation
express copied to clipboard

fix(res): throw error when res.redirect(undefined) is called

Open BOXER78 opened this issue 3 weeks ago • 0 comments

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

BOXER78 avatar Dec 03 '25 17:12 BOXER78