Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Created April 29, 2019 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebrind/29ae1e768d82254f2ee8951a7c506f5c to your computer and use it in GitHub Desktop.
Save mikebrind/29ae1e768d82254f2ee8951a7c506f5c to your computer and use it in GitHub Desktop.
using Microsoft.AspNetCore.Routing;
using System.Text.RegularExpressions;
public class HyphenateRouteParameterTransformer : IOutboundParameterTransformer
{
public string TransformOutbound(object value)
{
if (value == null)
{
return null;
}
return Regex.Replace(value.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment