match method

bool match(
  1. String arg
)

Implementation

bool match(String arg) {
  for (var i = 0; i < comps.length; i++) {
    final comp = comps[i];
    final lastChunk = i == comps.length - 1;
    if (comp is Wildcard && comp.literal.isEmpty) {
      return true;
    }
    var t = _matchChunk(comp.literal, arg);
    if (t != null && (t.isEmpty || !lastChunk)) {
      arg = t;
      continue;
    }
    if (comp is Wildcard) {
      for (var i = 0; i < arg.length; i++) {
        t = _matchChunk(comp.literal, arg.substring(i + 1));
        if (t != null) {
          if (lastChunk && t.isNotEmpty) {
            continue;
          }
          arg = t;
          continue;
        }
      }
    }
    return false;
  }
  return arg.isEmpty;
}