first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace SequenceAuth.Example.Infrastructure;
|
||||
|
||||
public class KebabCaseParameterTransformer : IOutboundParameterTransformer
|
||||
{
|
||||
public string? TransformOutbound(object? value)
|
||||
{
|
||||
return value == null ? null : value.ToString()!.ToKebabCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class StringExtension
|
||||
{
|
||||
[GeneratedRegex("([a-z0-9])([A-Z])", RegexOptions.Compiled)]
|
||||
private static partial Regex KebabCaseRule();
|
||||
|
||||
public static string ToKebabCase(this string input)
|
||||
=> KebabCaseRule().Replace(input, "$1-$2").ToLower().Trim('-');
|
||||
}
|
||||
Reference in New Issue
Block a user