Files
Umbraco-CMS/src/Umbraco.Web.Common/Extensions/LinkParserExtensions.cs
Justin Neville e2b8cc7060 Fix for issue 13017 - BeginUmbracoForm doesn't work with custom umbraco routes (#13103)
* Fix issue with custom Umbraco routes not working after submitting to a Surface controller

* Added comments

* Fixed breaking changes

* Fixed test by using correct new ctor

* Fixed initializtion of UmbracoRouteValueTransformer due to ambiguous ctor

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2022-12-06 12:40:47 +01:00

32 lines
978 B
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Umbraco.Cms.Web.Common.Extensions;
/// <summary>
/// Extension methods for LinkParser.
/// </summary>
public static class LinkParserExtensions
{
/// <summary>
/// Parses the path using the specified endpoint and returns the route values if a the path matches the route pattern.
/// </summary>
/// <param name="linkParser">The link parser.</param>
/// <param name="endpoint">The endpoint.</param>
/// <param name="path">The path to parse.</param>
/// <returns>The route values if the path matches or null.</returns>
public static RouteValueDictionary? ParsePathByEndpoint(this LinkParser linkParser, Endpoint endpoint, PathString path)
{
var name = endpoint.GetRouteName();
if (name != null)
{
return linkParser.ParsePathByEndpointName(name, path);
}
else
{
return null;
}
}
}