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

4.19.0 breaks passing new URL() into res.redirect(...) #5554

Closed
kavika-1 opened this issue Mar 20, 2024 · 7 comments
Closed

4.19.0 breaks passing new URL() into res.redirect(...) #5554

kavika-1 opened this issue Mar 20, 2024 · 7 comments
Labels

Comments

@kavika-1
Copy link

Understandably, res.redirect(...) should take a string. But for years we have been successfully passing a new URL(). We can certainly fix this on our side, but wanted to give a heads-up that this change might cause others to run into the same thing.

Error ultimately is thrown here:

reponse.js:915
var lowerLoc = loc.toLowerCase();

@kavika-1 kavika-1 added the bug label Mar 20, 2024
@wesleytodd
Copy link
Member

Ahhhh, yep that is not covered in the tests. I can prep a patch for that.

@wesleytodd
Copy link
Member

wesleytodd commented Mar 20, 2024

@kavika-1 Do you have a code snippet example of what you are doing so I can make sure this covers your case?

@wesleytodd
Copy link
Member

Can you check the PR to ensure it would cover you? CI is failing because of #5552 but I can merge this all together for the patch if this will fix your report.

@kavika-1
Copy link
Author

Example Code snippet, which should be fixed with this patch, thanks!

    const url = new URL(config.url);
    if (req.query.app) {
      url.searchParams.append('app', req.query.app);
    }
    res.redirect(url);

@wesleytodd
Copy link
Member

Published with 4.19.1. Thanks for the quick report, this would certainly have been something lots of folks hit.

@kavika-1
Copy link
Author

Amazing turnaround, thanks @wesleytodd!

@ddolcimascolo
Copy link

Ahah nice. I was hit by this and double checked the documentation. Clearly res.location accepts only a string so I patched my code to pass url.href instead of the url object and I could merge 4.19.0 just to discover a PR upgrading to 4.19.1 moments later for exactly this issue 😊

Thanks for your reactivity!

Cheers,
David

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

No branches or pull requests

3 participants