Skip to content

Commit b1aed4d

Browse files
radenokelset
authored andcommitted
Normalize scheme for URL on Android (facebook#21561)
Summary: Android requires lowercase for URL scheme. This commit facebook@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: facebook#21561 Differential Revision: D10287868 Pulled By: hramos fbshipit-source-id: f5e474164fdb2cfd49bd8ee51da17de3f1341a9c
1 parent 09178f8 commit b1aed4d

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

Libraries/Linking/Linking.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ class Linking extends NativeEventEmitter {
5757
* See https://facebook.github.io/react-native/docs/linking.html#openurl
5858
*/
5959
openURL(url: string): Promise<any> {
60-
// Android Intent requires protocols http and https to be in lowercase.
61-
// https:// and http:// works, but Https:// and Http:// doesn't.
62-
if (url.toLowerCase().startsWith('https://')) {
63-
url = url.replace(url.substr(0, 8), 'https://');
64-
} else if (url.toLowerCase().startsWith('http://')) {
65-
url = url.replace(url.substr(0, 7), 'http://');
66-
}
6760
this._validateURL(url);
6861
return LinkingManager.openURL(url);
6962
}

ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void openURL(String url, Promise promise) {
7979

8080
try {
8181
Activity currentActivity = getCurrentActivity();
82-
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
82+
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url).normalizeScheme());
8383

8484
String selfPackageName = getReactApplicationContext().getPackageName();
8585
ComponentName componentName = intent.resolveActivity(

0 commit comments

Comments
 (0)