From 0022947c00270d21266b8ddd78f7fffd3d67316a Mon Sep 17 00:00:00 2001 From: minodisk Date: Fri, 19 Feb 2016 13:52:08 +0900 Subject: [PATCH] Fix bug in multi comment --- model/post.go | 2 +- model/post_test.go | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/model/post.go b/model/post.go index b4af035..bd8e8ee 100644 --- a/model/post.go +++ b/model/post.go @@ -32,7 +32,7 @@ const ( ) var ( - rPostDecoder = regexp.MustCompile(`^(?ms:\n*\n{2,}# +(.*?)\n+(.*))$`) + rPostDecoder = regexp.MustCompile(`^(?ms:\n*\n{2,}# +(.*?)\n+(.*))$`) tmpl = func() (t *template.Template) { t = template.New("postfile") template.Must(t.Parse(postTemplate)) diff --git a/model/post_test.go b/model/post_test.go index 29f20b5..11e719d 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -1733,6 +1733,37 @@ Paragraph } } +func TestPostDecodeWithMultiComment(t *testing.T) { + testutil.CleanUp() + defer testutil.CleanUp() + + var post model.Post + err := post.Decode([]byte(` + +# Example Title + + + +# This is not title of this post +`)) + if err != nil { + t.Fatal(err) + } +} + func TestPostDecodeWithWrongTag(t *testing.T) { testutil.CleanUp() defer testutil.CleanUp() @@ -1765,7 +1796,7 @@ Paragraph } } -func TestDecodeWithWrongTitle(t *testing.T) { +func TestPostDecodeWithWrongTitle(t *testing.T) { testutil.CleanUp() defer testutil.CleanUp()