extractHost static method
Implementation
static String extractHost(String url) {
final regex = RegExp(
r'^(?:[^/]+\.)?([^./]+\.[^./]+(?:\.[^./]+)?)?(?:\.[^./]+)?(?=/|$)');
String mainPart = Uri.parse(url).host;
final match = regex.firstMatch(mainPart);
return match != null ? match.group(1) ?? mainPart : mainPart;
}