matchRoute method
Implementation
MatchResult? matchRoute(String path) {
final uri = Uri.parse(path);
final segments = _parsePath(uri.path);
var currentNode = _root;
final parameters = <String, String>{};
final urlParameters = uri.queryParameters;
for (final segment in segments) {
if (segment.isEmpty) continue;
final child = _findChild(currentNode, segment);
if (child == null) {
return null;
} else {
if (child.path.startsWith(":")) {
parameters[child.path.substring(1)] = segment;
}
if (child.nodeSegments.length == segments.length) {
return null;
}
currentNode = child;
}
}
return MatchResult(
currentNode,
parameters,
path,
urlParameters: urlParameters,
);
}