RouteSegment constructor

RouteSegment(
  1. String segment
)

Implementation

RouteSegment(String segment) {
  if (segment == "*") {
    isRemainingMatcher = true;
    return;
  }

  final regexIndex = segment.indexOf("(");
  if (regexIndex != -1) {
    final regexText = segment.substring(regexIndex + 1, segment.length - 1);
    matcher = RegExp(regexText);

    segment = segment.substring(0, regexIndex);
  }

  if (segment.startsWith(":")) {
    variableName = segment.substring(1, segment.length);
  } else if (regexIndex == -1) {
    literal = segment;
  }
}