Created
April 29, 2019 06:41
-
-
Save mikebrind/29ae1e768d82254f2ee8951a7c506f5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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