Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw when the path is undefined in res.redirect. #6391

Open
bjohansebas opened this issue Mar 16, 2025 · 4 comments · May be fixed by #6404 or #6405
Open

Throw when the path is undefined in res.redirect. #6391

bjohansebas opened this issue Mar 16, 2025 · 4 comments · May be fixed by #6404 or #6405

Comments

@bjohansebas
Copy link
Member

I think it would make sense to throw an error when the path is undefined in res.redirect. The current behavior redirects to /undefined, which I wouldn't consider very intuitive.

This functionality would be a breaking change, so it could be a candidate for Express 6. What do you all think?

@banskotanup
Copy link

I think throwing an error will be great whenever path is undefined in res.redirect.

@baltej223
Copy link

Yep, it's pretty intuitive to throw an error rather than redirect to /undefined

@dpopp07
Copy link
Contributor

dpopp07 commented Mar 17, 2025

The current behavior redirects to /undefined, which I wouldn't consider very intuitive.

Agreed - that sounds like the kind of sneaky, unexpected behavior that is hard to debug. The path is also documented as required so an error would make sense (as a side note, I find it odd that the optional argument comes first for this method - that's not a great practice and most of the other methods don't do that).

@bjohansebas
Copy link
Member Author

(as a side note, I find it odd that the optional argument comes first for this method - that's not a great practice and most of the other methods don't do that)

Interesting that this was deprecated in v4 and removed in v5 (See #2941), it probably should never have been that way. I also find it just as strange that the optional argument is the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants