18 lines
643 B
C#
18 lines
643 B
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System;
|
|
using System.Text.RegularExpressions;
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
namespace RoutingWebSite
|
|
{
|
|
public class SlugifyParameterTransformer : IOutboundParameterTransformer
|
|
{
|
|
public string TransformOutbound(object value)
|
|
{
|
|
// Slugify value
|
|
return value == null ? null : Regex.Replace(value.ToString(), "([a-z])([A-Z])", "$1-$2", RegexOptions.None, TimeSpan.FromMilliseconds(100)).ToLower();
|
|
}
|
|
}
|
|
} |