parseDomainPattern static method

Pattern parseDomainPattern(
  1. Pattern domainPatter
)

Parses a domain pattern.

Implementation

static Pattern parseDomainPattern(Pattern domainPatter) {
  if (domainPatter is RegExp) return domainPatter;

  var s = domainPatter.toString().trim();

  if (s.startsWith('r/') && s.endsWith('/')) {
    var re = s.substring(2, s.length - 1);
    return RegExp(re);
  }

  if (s == '*' || s == '.') {
    return RegExp(r'.*');
  }

  return s;
}