checkStatus method

Future<UrlStatus> checkStatus(
  1. String url
)

Check the status of the URL, using validity checks, cache and safe URL checks with limited number of redirects.

Implementation

Future<UrlStatus> checkStatus(String url) async {
  final uri = Uri.tryParse(url);
  if (uri == null) {
    return UrlStatus.invalid();
  }
  if (uri.scheme != 'http' && uri.scheme != 'https') {
    return UrlStatus.invalid();
  }
  // The safe URL check will verify if the resolved IP of the host name
  // seems to be valid (e.g. not an a local loopback, multicast or private network).
  final exists = await checkUrlExists(uri);
  return UrlStatus(
    isInvalid: false,
    isSecure: uri.scheme == 'https',
    exists: exists,
  );
}