getDomainFromUrl static method

Domain? getDomainFromUrl(
  1. String url
)

Fetches the domain from the given url Returns null if the given url is not parsable.

Implementation

static Domain? getDomainFromUrl(String url) {
  url = url.replaceFirst('https://', '');
  url = url.replaceFirst('http://', '');
  if (url.contains('/')) {
    url = url.substring(0, url.indexOf('/'));
  }
  return parseDomain(url);
}