booking-microservices/building-blocks/Web/SlugifyParameterTransformer.cs
2025-03-15 16:54:20 +03:30

17 lines
472 B
C#

using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Routing;
namespace BuildingBlocks.Web;
public class SlugifyParameterTransformer : IOutboundParameterTransformer
{
public string TransformOutbound(object value)
{
// Slugify value
return value == null
? null
: Regex.Replace(value.ToString() ?? string.Empty, "([a-z])([A-Z])", "$1-$2").ToLower(CultureInfo.CurrentCulture);
}
}