From 802f6cd0dbb14bbd57653ab5d4f2fe3cffcf01c9 Mon Sep 17 00:00:00 2001 From: Mark Downie Date: Fri, 14 Aug 2020 00:03:16 -0400 Subject: [PATCH] Ensure everything works for Unique URLS. --- source/DasBlog.Web.Repositories/BlogManager.cs | 8 ++++---- source/DasBlog.Web.UI/Mappers/ProfilePost.cs | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/DasBlog.Web.Repositories/BlogManager.cs b/source/DasBlog.Web.Repositories/BlogManager.cs index 7603b58e..b6a68969 100644 --- a/source/DasBlog.Web.Repositories/BlogManager.cs +++ b/source/DasBlog.Web.Repositories/BlogManager.cs @@ -42,11 +42,11 @@ public BlogManager( ILogger logger, IDasBlogSettings dasBlogSetting /// if non-null then the post must be dated on that date public Entry GetBlogPost(string posttitle, DateTime? dt) { - posttitle = posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement,string.Empty) - .Replace(".aspx", string.Empty); - if (dt == null) { + posttitle = posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, string.Empty) + .Replace(".aspx", string.Empty); + return dataService.GetEntry(posttitle); } else @@ -54,7 +54,7 @@ public Entry GetBlogPost(string posttitle, DateTime? dt) var entries = dataService.GetEntriesForDay(dt.Value, null, null, 1, 10, null); return entries.FirstOrDefault(e => dasBlogSettings.GeneratePostUrl(e) - .Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, string.Empty) == posttitle); + .EndsWith(posttitle, StringComparison.OrdinalIgnoreCase)); } } diff --git a/source/DasBlog.Web.UI/Mappers/ProfilePost.cs b/source/DasBlog.Web.UI/Mappers/ProfilePost.cs index f90d084f..535182eb 100644 --- a/source/DasBlog.Web.UI/Mappers/ProfilePost.cs +++ b/source/DasBlog.Web.UI/Mappers/ProfilePost.cs @@ -77,8 +77,9 @@ public ProfilePost(IDasBlogSettings dasBlogSettings) CreateMap() .ForMember(dest => dest.BlogTitle, opt => opt.MapFrom(src => src.Title)) - .ForMember(dest => dest.BlogId, opt => opt.MapFrom(src => src.EntryId)); - + .ForMember(dest => dest.BlogId, opt => opt.MapFrom(src => _dasBlogSettings.GeneratePostUrl(src))) + .ForMember(dest => dest.Category, opt => opt.MapFrom(src => src.GetSplitCategories().FirstOrDefault())) + .ForMember(dest => dest.Date, opt => opt.MapFrom(src => src.CreatedLocalTime)); CreateMap() .ForMember(dest => dest.Allowed, opt => opt.MapFrom(src => src.Allowed))