matchRoute static method

(RouteDefiner?, bool) matchRoute(
  1. String path
)

Matches a given path against the list of registered routes.

Returns a tuple with the matching RouteDefiner (or null) and a boolean indicating if the path is a near match.

Implementation

static (RouteDefiner?, bool) matchRoute(String path) {
  for (var route in _routes) {
    final params = extractPathParams(route.path, path);
    if (params != null) return (route, false);
    if (isNearMatch(route.path, path)) return (null, true);
  }
  return (null, false);
}