parseDomainEntry static method

MapEntry<Pattern, Directory?>? parseDomainEntry(
  1. Object? o, {
  2. bool checkDirectoryExistence = false,
})

Parses a domain entry as MapEntry.

Implementation

static MapEntry<Pattern, Directory?>? parseDomainEntry(Object? o,
    {bool checkDirectoryExistence = false}) {
  if (o == null) return null;
  if (o is MapEntry) {
    return MapEntry(
        parseDomainPattern(o.key),
        parseDomainDirectory(o.value,
            checkDirectoryExistence: checkDirectoryExistence));
  }

  var s = o.toString();

  var parts = s.split('=');
  var domain = parts[0].trim();
  var path = parts.length > 1 ? parts[1].trim() : '';

  return MapEntry(
      parseDomainPattern(domain),
      parseDomainDirectory(path,
          checkDirectoryExistence: checkDirectoryExistence));
}