diff --git a/post.go b/post.go index 90eb5cf..a4d4ab0 100644 --- a/post.go +++ b/post.go @@ -181,6 +181,8 @@ func (post *Post) RenderedContent() string { // trim yaml block // TODO this can be done nicer trimmedData := bytes.TrimSpace(data) + // ensure that data ends with a newline + trimmedData = append(trimmedData, []byte("\n")...) // check first line is --- if string(trimmedData[0:4]) == "---\n" { trimmedData = trimmedData[4:] diff --git a/post_test.go b/post_test.go index 67b30a9..898bf72 100644 --- a/post_test.go +++ b/post_test.go @@ -465,6 +465,15 @@ func TestComplexParallelWebmentions(t *testing.T) { assertions.AssertLen(t, outs, 20) } +func TestPostWithoutContent(t *testing.T) { + repo := getTestRepo(owl.RepoConfig{}) + user, _ := repo.CreateUser("testuser") + post, _ := user.CreateNewPostFull(owl.PostMeta{}, "") + + result := post.RenderedContent() + assertions.AssertEqual(t, result, "") +} + // func TestComplexParallelSimulatedProcessesWebmentions(t *testing.T) { // repoName := testRepoName() // repo, _ := owl.CreateRepository(repoName, owl.RepoConfig{})