#19362: Adding Dot to Regex and tests around story.

Work Item: 19362

--HG--
branch : 1.x
This commit is contained in:
Nicholas Mayne
2013-06-07 23:29:15 +01:00
parent 4201d98954
commit 09aec8fac9
2 changed files with 22 additions and 1 deletions

View File

@@ -29,5 +29,26 @@ namespace Orchard.Tests.Modules.Autoroute {
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"));
}
}
}

View File

@@ -26,7 +26,7 @@ namespace Orchard.Autoroute.Services {
if (!slugContext.Adjusted) {
var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\\|%]+");
var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+");
var cleanedSlug = disallowed.Replace(slugContext.Title, "-").Trim('-','.');