Adding tests for HijackedRouteEvaluator

This commit is contained in:
Shannon
2021-01-12 16:28:00 +11:00
parent 24a395f1ea
commit a83cbc00ef
2 changed files with 105 additions and 2 deletions

View File

@@ -50,14 +50,22 @@ namespace Umbraco.Web.Website.Routing
&& TypeHelper.IsTypeAssignableFrom<ControllerBase>(controllerDescriptor.ControllerTypeInfo))
{
// now check if the custom action matches
var customActionExists = action != null && customControllerCandidates.Any(x => x.ActionName.InvariantEquals(action));
var resultingAction = DefaultActionName;
if (action != null)
{
var found = customControllerCandidates.FirstOrDefault(x => x.ActionName.InvariantEquals(action))?.ActionName;
if (found != null)
{
resultingAction = found;
}
}
// it's a hijacked route with a custom controller, so return the the values
return new HijackedRouteResult(
true,
controllerDescriptor.ControllerName,
controllerDescriptor.ControllerTypeInfo,
customActionExists ? action : DefaultActionName);
resultingAction);
}
else
{