mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-15 13:53:34 +08:00
parent
4eff84d2f7
commit
5d55e95506
@ -80,6 +80,22 @@ namespace Orchard.Core.Tests.Routable.Services {
|
||||
Assert.That(thing.Slug, Is.EqualTo("please-do-not-use-any-of-the-following-characters-in-your-slugs"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SpacesSlugShouldBeTreatedAsEmpty() {
|
||||
var contentManager = _container.Resolve<IContentManager>();
|
||||
|
||||
var thing = contentManager.Create<Thing>("thing", t => {
|
||||
t.As<RoutePart>().Record = new RoutePartRecord();
|
||||
t.Title = "My Title";
|
||||
t.Slug = " ";
|
||||
});
|
||||
|
||||
_routableService.FillSlugFromTitle(thing.As<RoutePart>());
|
||||
|
||||
Assert.That(thing.Slug, Is.EqualTo("my-title"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void SlashInSlugIsAllowed() {
|
||||
Assert.That(_routableService.IsSlugValid("some/page"), Is.True);
|
||||
|
@ -47,7 +47,7 @@ namespace Orchard.Core.Routable.Services {
|
||||
}
|
||||
|
||||
public void FillSlugFromTitle<TModel>(TModel model) where TModel : IRoutableAspect {
|
||||
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))
|
||||
if ((model.Slug != null && !string.IsNullOrEmpty(model.Slug.Trim())) || string.IsNullOrEmpty(model.Title))
|
||||
return;
|
||||
|
||||
FillSlugContext slugContext = new FillSlugContext(model.Title);
|
||||
|
@ -10,7 +10,6 @@ namespace Orchard.Core.Routable.ViewModels {
|
||||
[StringLength(1024)]
|
||||
public string Title { get; set; }
|
||||
[StringLength(1024)]
|
||||
[Required(AllowEmptyStrings = false)]
|
||||
public string Slug { get; set; }
|
||||
public int? ContainerId { get; set; }
|
||||
public bool PromoteToHomePage { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user