2021-03-31 21:16:23 +02:00
|
|
|
/// Returns host of a url without a leading 'www.' or protocol if present also
|
|
|
|
/// removes trailing '/'
|
2021-03-31 21:28:46 +02:00
|
|
|
String cleanUpUrl(String url) {
|
|
|
|
try {
|
|
|
|
return urlHost(url.startsWith('https://') ? url : 'https://$url');
|
|
|
|
} on FormatException catch (_) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
2021-01-27 20:53:09 +01:00
|
|
|
|
|
|
|
// Returns host of a url without a leading 'www.' if present
|
|
|
|
String urlHost(String url) {
|
|
|
|
final host = Uri.parse(url).host;
|
|
|
|
|
|
|
|
if (host.startsWith('www.')) {
|
|
|
|
return host.substring(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return host;
|
|
|
|
}
|