From 4b6f02ea758a9ab5853a29ebfc054eaa98e6dc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20=C5=A0mitala?= Date: Tue, 9 Oct 2018 23:22:22 -0700 Subject: [PATCH] Normalize scheme for URL on Android (#21561) Summary: Android requires lowercase for URL scheme. This commit https://github.com/facebook/react-native/commit/d00bdb9bb8b9b11bce900689c7e28cebd2eb0807 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: https://github.com/facebook/react-native/pull/21561 Differential Revision: D10287868 Pulled By: hramos fbshipit-source-id: f5e474164fdb2cfd49bd8ee51da17de3f1341a9c --- Libraries/Linking/Linking.js | 7 ------- .../com/facebook/react/modules/intent/IntentModule.java | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index 309ce5824..bcb885b0a 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -57,13 +57,6 @@ class Linking extends NativeEventEmitter { * See https://facebook.github.io/react-native/docs/linking.html#openurl */ openURL(url: string): Promise { - // 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); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java index 6187c943e..a7b848258 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java @@ -79,7 +79,7 @@ public class IntentModule extends ReactContextBaseJavaModule { 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(