From ab108be50c8d861ba052b96686badcdc64b45563 Mon Sep 17 00:00:00 2001 From: Micah Morrison Date: Mon, 11 Mar 2024 11:30:33 -0400 Subject: [PATCH] Fix non-standard protocol handling --- lib/utils/links.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/utils/links.dart b/lib/utils/links.dart index 00eb86eca..b8761031f 100644 --- a/lib/utils/links.dart +++ b/lib/utils/links.dart @@ -96,11 +96,19 @@ void _openLink(BuildContext context, {required String url}) async { ), ); } else if (state.browserMode == BrowserMode.inApp) { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => WebView(url: url), - ), - ); + // Check if the scheme is not https, in which case the in-app browser can't handle it + Uri? uri = Uri.tryParse(url); + if (uri != null && uri.scheme != 'https') { + // Although a non-https scheme is an indication that this link is intended for another app, + // we actually have to change it back to https in order for the intent to be properly passed to another app. + url_launcher.launchUrl(uri, mode: url_launcher.LaunchMode.externalApplication); + } else { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => WebView(url: url), + ), + ); + } } }