Skip to content

Commit 3dc38d4

Browse files
committed
Smaller refactoring
1 parent 200e781 commit 3dc38d4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/LinkDotNet.Blog.Domain/BlogPost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static BlogPost Create(
116116
PreviewImageUrl = previewImageUrl,
117117
PreviewImageUrlFallback = previewImageUrlFallback,
118118
IsPublished = isPublished,
119-
Tags = tags?.Select(t => t.Trim()).ToImmutableArray(),
119+
Tags = tags?.Select(t => t.Trim()).ToImmutableArray() ?? ImmutableArray<string>.Empty,
120120
ReadingTimeInMinutes = ReadingTimeCalculator.CalculateReadingTime(content),
121121
};
122122

src/LinkDotNet.Blog.Web/Features/Admin/BlogPostEditor/Components/CreateNewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public static CreateNewModel FromBlogPost(BlogPost blogPost)
108108

109109
public BlogPost ToBlogPost()
110110
{
111-
var tagList = string.IsNullOrWhiteSpace(Tags) ? ArraySegment<string>.Empty : Tags.Split(",");
111+
var tagList = string.IsNullOrWhiteSpace(Tags)
112+
? Array.Empty<string>()
113+
: Tags.Split(",", StringSplitOptions.RemoveEmptyEntries);
112114
DateTime? updatedDate = ShouldUpdateDate || originalUpdatedDate == default
113115
? null
114116
: originalUpdatedDate;

0 commit comments

Comments
 (0)