getSecuredRouteFromRouteName static method

FxRoute? getSecuredRouteFromRouteName(
  1. String routeName
)

Implementation

static FxRoute? getSecuredRouteFromRouteName(String routeName) {
  Uri uri = Uri.parse(routeName);
  var _route = uri.path;
  FxRoute? route = _getRouteFromRouteName(_route);
  if (route == null) return null;

  if (route.middlewares != null && route.middlewares!.isNotEmpty) {
    for (FxMiddleware middleware in route.middlewares!) {
      String redirectedRouteName = middleware.handle(_route);
      if (redirectedRouteName.compareTo(_route) != 0) {
        return getSecuredRouteFromRouteName(redirectedRouteName);
      }
    }
  }
  return route;
}