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

Improved absolute redirect url detection in actions/loaders #9829

Merged

Conversation

lkwr
Copy link
Contributor

@lkwr lkwr commented Jan 7, 2023

This solves the issue remix-run/remix#5002.

With this change, we are able to redirect to URI's like mailto:[email protected] before this change it was not possible because it was interpreted as a relative path.

The regex comes from https://stackoverflow.com/a/31991870 and should match all common absolute URLs and URIs including string starting with //.

I tested it with in my own project and it worked like a charm!

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2023

⚠️ No Changeset found

Latest commit: 742d2b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 7, 2023

Hi @lkwr,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 7, 2023

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@brophdawg11
Copy link
Contributor

Thanks! Would you mind adding a unit test for mailto: links as well? You may be able to just add it to the urls in the "should handle external redirect Responses" test in router-test.ts

@lkwr
Copy link
Contributor Author

lkwr commented Jan 9, 2023

Done, I have also added a web+ prefix url which can be used too.

@brophdawg11 brophdawg11 self-assigned this Jan 11, 2023
@brophdawg11 brophdawg11 changed the base branch from dev to release-next January 11, 2023 18:38
@brophdawg11 brophdawg11 merged commit c0f1b98 into remix-run:release-next Jan 11, 2023
@lkwr lkwr deleted the lkwr/absolute-redirect-detection branch January 27, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants