CedarPattern.parse constructor

CedarPattern.parse(
  1. String pattern
)

Implementation

factory CedarPattern.parse(String pattern) {
  final components = <CedarPatternComponent>[];
  final scanner = StringScanner(pattern);
  while (!scanner.isDone) {
    while (!scanner.isDone && scanner.peekChar() == Character.star) {
      scanner.readChar();
      components.add(Wildcard());
    }
    final literal = scanner.readUnquoted(star: true);
    if (literal.isNotEmpty) {
      components.add(Literal(literal));
    }
  }
  return CedarPattern.from(components, raw: pattern);
}