From 09178f8bb905e3c305f84833bdfc8d4c12f66618 Mon Sep 17 00:00:00 2001 From: Hyunjong Lee Date: Sat, 29 Sep 2018 11:48:15 -0700 Subject: [PATCH] Resolve protocol http, https when not in lowercase (#21396) Summary: Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. _Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_ Pull Request resolved: https://github.com/facebook/react-native/pull/21396 Differential Revision: D10119630 Pulled By: RSNara fbshipit-source-id: d0fe193eee976b9b18a2eb467b5f3af48bd7d2de --- Libraries/Linking/Linking.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index fec44f634fa..43760fbd972 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -57,6 +57,13 @@ 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); }