Parcourir la source

fix: could not open link without scheme

Lucas.Xu il y a 2 ans
Parent
commit
1cd9a77e00

+ 7 - 1
frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart

@@ -277,7 +277,13 @@ class RichTextStyle {
     if (href != null) {
       return TapGestureRecognizer()
         ..onTap = () async {
-          await launchUrlString(href);
+          final uri = Uri.parse(href);
+          // url_launcher cannot open a link without scheme.
+          final newHref =
+              (uri.scheme.isNotEmpty ? href : 'http://$href').trim();
+          if (await canLaunchUrlString(newHref)) {
+            await launchUrlString(newHref);
+          }
         };
     }
     return null;