mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 03:17:32 +08:00
#19362: Adding Dot to Regex and tests around story.
Work Item: 19362 --HG-- branch : 1.x
This commit is contained in:
@@ -29,5 +29,26 @@ namespace Orchard.Tests.Modules.Autoroute {
|
|||||||
|
|
||||||
Assert.That(slugService.Slugify("a - b - c -- d"), Is.EqualTo("a-b-c-d"));
|
Assert.That(slugService.Slugify("a - b - c -- d"), Is.EqualTo("a-b-c-d"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ShouldChangePercentSymbolsToHyphans() {
|
||||||
|
DefaultSlugService slugService = new DefaultSlugService(new Mock<ISlugEventHandler>().Object);
|
||||||
|
|
||||||
|
Assert.That(slugService.Slugify("a%d"), Is.EqualTo("a-d"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ShouldChangeDotSymbolsToHyphans() {
|
||||||
|
DefaultSlugService slugService = new DefaultSlugService(new Mock<ISlugEventHandler>().Object);
|
||||||
|
|
||||||
|
Assert.That(slugService.Slugify("a,d"), Is.EqualTo("a-d"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ShouldMakeSureFunkycharactersAndHyphansOnlyReturnSingleHyphan() {
|
||||||
|
DefaultSlugService slugService = new DefaultSlugService(new Mock<ISlugEventHandler>().Object);
|
||||||
|
|
||||||
|
Assert.That(slugService.Slugify("a-%-.d"), Is.EqualTo("a-d"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Orchard.Autoroute.Services {
|
|||||||
|
|
||||||
if (!slugContext.Adjusted) {
|
if (!slugContext.Adjusted) {
|
||||||
|
|
||||||
var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\\|%]+");
|
var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+");
|
||||||
|
|
||||||
var cleanedSlug = disallowed.Replace(slugContext.Title, "-").Trim('-','.');
|
var cleanedSlug = disallowed.Replace(slugContext.Title, "-").Trim('-','.');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user