Don't attempt to navigate to invalid URLs #163
Merged
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.
Currently Turbo Native will attempt to navigate to any link, even if it's not a valid URL. This can cause the app to crash (here) if you click on a link like
sms:+55555555?body=hi
, sinceURL(location)
doesn't recognisesms:
links as valid.To properly handle this you should implement this code. But if you forget to, or if someone working on the web app ships a new link without you knowing about it, you don't want this to cause a scenario where clicking a link can crash the native app.
This PR avoids that, by not navigating to a link that can't be parsed to a URL by default. Now, rather than crashing the app, the link does nothing. Still not great, but not as bad.
If you've overridden
shouldNavigateTo
this shouldn't change anything for you.