From 52d057f2e3f6e87be640320c98dbe3d4d5195da9 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 25 Aug 2019 13:14:11 +0200 Subject: [PATCH] Guard for empty page --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 6b72c83..3eb3322 100644 --- a/main.go +++ b/main.go @@ -332,7 +332,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { pageText := mp.Get(page).Content - jsonEditor := pageText[0] == '{' + jsonEditor := pageText != "" && pageText[0] == '{' var editor template.HTML if jsonEditor { @@ -401,7 +401,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - jsonPage := pageText[0] == '{' + jsonPage := pageText != "" && pageText[0] == '{' if jsonPage { pageText, err = renderJSON(pageText)