From c5f75c94ad0209a7e8199cad0aed6a059b3a161a Mon Sep 17 00:00:00 2001 From: ryg-git Date: Thu, 1 Apr 2021 00:58:46 +0530 Subject: [PATCH] handle FormatException thrown by Uri.parse --- lib/util/cleanup_url.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/util/cleanup_url.dart b/lib/util/cleanup_url.dart index 6f3f610..f8182fd 100644 --- a/lib/util/cleanup_url.dart +++ b/lib/util/cleanup_url.dart @@ -1,7 +1,12 @@ /// Returns host of a url without a leading 'www.' or protocol if present also /// removes trailing '/' -String cleanUpUrl(String url) => - urlHost(url.startsWith('https://') ? url : 'https://$url'); +String cleanUpUrl(String url) { + try { + return urlHost(url.startsWith('https://') ? url : 'https://$url'); + } on FormatException catch (_) { + return ''; + } +} // Returns host of a url without a leading 'www.' if present String urlHost(String url) {