handle FormatException thrown by Uri.parse

This commit is contained in:
ryg-git 2021-04-01 00:58:46 +05:30
parent 725f9103d6
commit c5f75c94ad
1 changed files with 7 additions and 2 deletions

View File

@ -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) {