Skip to content

fix: non standard status code will result in undefined#7045

Open
cuiweixie wants to merge 2 commits intoexpressjs:masterfrom
cuiweixie:statusMessage
Open

fix: non standard status code will result in undefined#7045
cuiweixie wants to merge 2 commits intoexpressjs:masterfrom
cuiweixie:statusMessage

Conversation

@cuiweixie
Copy link

No description provided.

Copy link

@erdinccurebal erdinccurebal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — statuses.message[status] returns undefined for non-standard status codes, which results in the redirect body being "undefined. Redirecting to /foo".

The fallback to String(status) makes sense. One thing to note: the html format callback a few lines below has the same pattern:

html: function(){
  var u = escapeHtml(address);
  body = '<p>' + statuses.message[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>'
},

This would also produce "<p>undefined. Redirecting to..." for non-standard codes. Might be worth applying the same fallback there for consistency.

@cuiweixie
Copy link
Author

Good catch — statuses.message[status] returns undefined for non-standard status codes, which results in the redirect body being "undefined. Redirecting to /foo".

The fallback to String(status) makes sense. One thing to note: the html format callback a few lines below has the same pattern:

html: function(){
  var u = escapeHtml(address);
  body = '<p>' + statuses.message[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>'
},

This would also produce "<p>undefined. Redirecting to..." for non-standard codes. Might be worth applying the same fallback there for consistency.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants