Skip to content

Commit

Permalink
Normalize scheme for URL on Android (#21561)
Browse files Browse the repository at this point in the history
Summary:
Android requires lowercase for URL scheme. This commit d00bdb9 fixed it but on React Native side.
Because it is Android specific, it should be fixed on Android side.

Android has method to normalize url scheme: https://developer.android.com/reference/android/net/Uri.html#normalizeScheme()
Pull Request resolved: #21561

Differential Revision: D10287868

Pulled By: hramos

fbshipit-source-id: f5e474164fdb2cfd49bd8ee51da17de3f1341a9c
  • Loading branch information
radeno authored and facebook-github-bot committed Oct 10, 2018
1 parent 9965ea5 commit 4b6f02e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ class Linking extends NativeEventEmitter {
* See https://facebook.github.io/react-native/docs/linking.html#openurl
*/
openURL(url: string): Promise<any> {
// Android Intent requires protocols http and https to be in lowercase.
// https:// and http:// works, but Https:// and Http:// doesn't.
if (url.toLowerCase().startsWith('https://')) {
url = url.replace(url.substr(0, 8), 'https://');
} else if (url.toLowerCase().startsWith('http://')) {
url = url.replace(url.substr(0, 7), 'http://');
}
this._validateURL(url);
return LinkingManager.openURL(url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void openURL(String url, Promise promise) {

try {
Activity currentActivity = getCurrentActivity();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url).normalizeScheme());

String selfPackageName = getReactApplicationContext().getPackageName();
ComponentName componentName = intent.resolveActivity(
Expand Down

1 comment on commit 4b6f02e

@geomih
Copy link

@geomih geomih commented on 4b6f02e Oct 15, 2019

Choose a reason for hiding this comment

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

Why wasn't this added in the canOpenURL method?

Please sign in to comment.