handle FormatException thrown by Uri.parse
This commit is contained in:
parent
725f9103d6
commit
c5f75c94ad
|
@ -1,7 +1,12 @@
|
||||||
/// Returns host of a url without a leading 'www.' or protocol if present also
|
/// Returns host of a url without a leading 'www.' or protocol if present also
|
||||||
/// removes trailing '/'
|
/// removes trailing '/'
|
||||||
String cleanUpUrl(String url) =>
|
String cleanUpUrl(String url) {
|
||||||
urlHost(url.startsWith('https://') ? url : 'https://$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
|
// Returns host of a url without a leading 'www.' if present
|
||||||
String urlHost(String url) {
|
String urlHost(String url) {
|
||||||
|
|
Loading…
Reference in New Issue