Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize scheme for URL on Android #21561

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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