isAbsoluteUrl function

bool isAbsoluteUrl(
  1. String url
)

Is absolute URL / is relative path. Roadmap #174.

Implementation

bool isAbsoluteUrl(String url) {
  final String trimmed = url.trim();
  if (trimmed.isEmpty) return false;
  final int colonIndex = trimmed.indexOf(':');
  if (colonIndex <= 0) return false;
  final String scheme = trimmed.replaceRange(colonIndex, trimmed.length, '').toLowerCase();
  return scheme == _kSchemeHttp ||
      scheme == _kSchemeHttps ||
      scheme == _kSchemeFile ||
      scheme == _kSchemeFtp;
}