lemmur-app-android/lib/util/cleanup_url.dart

16 lines
414 B
Dart
Raw Normal View History

2021-03-31 21:16:23 +02:00
/// 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');
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;
}