Skip to content

Polish HTML structure of the response in the res.redirect() function #5167

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Bernice55231
Copy link

@Bernice55231 Bernice55231 commented Apr 16, 2023

Fixed #5058
To prevent the issue of not showing the DOM body in the old-versioned browser or HTTPServer in redirecting method, it is better to have the <!DOCTYPE html>' and <title>` elements in the response body. If we use an old-versioned browser, it may not automatically fulfill the correct HTML file and thus show only plain text on that page if it does not succeed in redirecting.

@kevinsandow
Copy link

Your changes look good to me, you just missed the tests for the redirect body in test/res.redirect.js.

@Bernice55231
Copy link
Author

Your changes look good to me, you just missed the tests for the redirect body in test/res.redirect.js.

Hi, I have updated the test file, could you review it again? Thank you!

@kevinsandow
Copy link

Looks good now, but I'm not the maintainer.

@bjohansebas
Copy link
Member

Hi @Bernice55231, would you like to resolve the conflicts in this PR?

@UlisesGascon
Copy link
Member

Keep in mind GHSA-qw6h-vgh9-j6wx when handling this conflict to prevent regressions :)

@bjohansebas bjohansebas requested a review from Copilot April 12, 2025 02:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

lib/response.js:840

  • The string concatenation split into multiple lines may risk issues with automatic semicolon insertion in JavaScript; consider moving the '+' operator to the end of the preceding line to ensure the concatenation works as intended.
+ '<body><p>' + statuses.message[status] + '. Redirecting to ' + u + '</p></body>'

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

Successfully merging this pull request may close these issues.

HTML in the res.redirect() method is missing a DOCTYPE and <title> element
5 participants