Implementation
RouteNode? nodeForPathSegments(
Iterator<String> requestSegments,
RequestPath path,
) {
if (!requestSegments.moveNext()) {
return this;
}
final nextSegment = requestSegments.current;
if (equalityChildren.containsKey(nextSegment)) {
return equalityChildren[nextSegment]!
.nodeForPathSegments(requestSegments, path);
}
for (final node in patternedChildren) {
if (node.patternMatcher == null) {
// This is a variable with no regular expression
return node.nodeForPathSegments(requestSegments, path);
}
if (node.patternMatcher!.firstMatch(nextSegment) != null) {
// This segment has a regular expression
return node.nodeForPathSegments(requestSegments, path);
}
}
// If this is null, then we return null from this method
// and the router knows we didn't find a match.
return takeAllChild;
}