Browse Source
Allow multiple level URLs in SlugNormalizer
pull/17642/head
Enis Necipoglu
3 years ago
No known key found for this signature in database
GPG Key ID: 1EC55E13241E1680
2 changed files with
22 additions and
1 deletions
-
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/SlugNormalizer.cs
-
modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Blogs/SlugExtensions_Tests.cs
|
|
|
@ -5,7 +5,14 @@ namespace Volo.CmsKit; |
|
|
|
|
|
|
|
public static class SlugNormalizer |
|
|
|
{ |
|
|
|
static readonly SlugHelper SlugHelper = new(); |
|
|
|
static readonly SlugHelper SlugHelper = new(new SlugHelperConfiguration |
|
|
|
{ |
|
|
|
AllowedChars = |
|
|
|
{ |
|
|
|
'/' |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
public static string Normalize(string value) |
|
|
|
{ |
|
|
|
return SlugHelper.GenerateSlug(value?.Unidecode()); |
|
|
|
|
|
|
|
@ -129,4 +129,18 @@ public class SlugExtensions_Tests |
|
|
|
// Assert
|
|
|
|
actual.ShouldBe(expected); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizeSlug_ShouldWorkProperly_WithMultipleLevel() |
|
|
|
{ |
|
|
|
// Arrange
|
|
|
|
var name = "path/to/my/page"; |
|
|
|
var expected = "path/to/my/page"; |
|
|
|
|
|
|
|
// Act
|
|
|
|
var actual = SlugNormalizer.Normalize(name); |
|
|
|
|
|
|
|
// Assert
|
|
|
|
actual.ShouldBe(expected); |
|
|
|
} |
|
|
|
} |
|
|
|
|