feat(res.redirect): add validation for url and status arguments#6404
Open
bjohansebas wants to merge 2 commits intomasterfrom
Open
feat(res.redirect): add validation for url and status arguments#6404bjohansebas wants to merge 2 commits intomasterfrom
bjohansebas wants to merge 2 commits intomasterfrom
Conversation
Member
UlisesGascon
left a comment
There was a problem hiding this comment.
I think is a good idea, but we will need to introduce the deprecation notice in 5.x before merging this PR 🤔
shivarm
reviewed
Mar 29, 2025
| var app = express(); | ||
|
|
||
| app.use(function (req, res) { | ||
| res.redirect("300", 'http://google.com') |
Contributor
There was a problem hiding this comment.
Suggested change
| res.redirect("300", 'http://google.com') | |
| res.redirect("300", 'https://google.com') |
http -> https
Member
There was a problem hiding this comment.
Not bad, but also just to be clear it is not necessary in the tests.
This was referenced Dec 11, 2025
7 tasks
krzysdz
reviewed
Feb 24, 2026
Comment on lines
836
to
839
| if (typeof status !== 'number') { | ||
| deprecate('Status must be a number'); | ||
| throw new TypeError('res.redirect: status must be a number'); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Status is set using this.status(status), which performs type validation (#4212). Earlier status is used to get a status message for body, but passing something invalid there is not a problem if an error is thrown before it's sent.
Suggested change
| if (typeof status !== 'number') { | |
| deprecate('Status must be a number'); | |
| throw new TypeError('res.redirect: status must be a number'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validations are being added, this would ideally be for Express 6. Maybe sending a deprecation message would be great, what do you think?
closes #6391