diff --git a/admin-app/post.go b/admin-app/post.go index 3469c3c..7462cb3 100644 --- a/admin-app/post.go +++ b/admin-app/post.go @@ -139,6 +139,10 @@ func deletePostHandler(database database.Database) func(*gin.Context) { // removing the given ranges func partitionString(text string, indexes [][]int) []string { + if len(text) == 0 { + return []string{} + } + partitions := make([]string, 0) start := 0 for _, window := range indexes { @@ -187,10 +191,15 @@ func transformContent(content string, shortcode_handlers map[string]*lua.LState) regex, _ := regexp.Compile(`{{[\w.-]+(:[\w.-]+)+}}`) shortcodes := regex.FindAllStringIndex(content, -1) + if len(shortcodes) == 0 { + return content, nil + } + partitions := partitionString(content, shortcodes) builder := strings.Builder{} i := 0 + for i, shortcode := range shortcodes { builder.WriteString(partitions[i]) diff --git a/app/app.go b/app/app.go index 76cf469..37b3f71 100644 --- a/app/app.go +++ b/app/app.go @@ -57,7 +57,7 @@ func addCachableHandler(e *gin.Engine, method string, endpoint string, generator if err != nil { log.Error().Msgf("could not generate html: %v", err) // TODO : Need a proper error page - // c.JSON(http.StatusInternalServerError, common.ErrorRes("could not render HTML", err)) + c.JSON(http.StatusInternalServerError, common.ErrorRes("could not render HTML", err)) return }