Skip to content

Commit

Permalink
Strip quotes when truncating
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Mar 21, 2024
1 parent 546ee23 commit 094f069
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions httplistener/templates.go
Expand Up @@ -3,10 +3,13 @@ package httplistener
import (
"bytes"
"errors"
"github.com/irccloud/irccat/util"
"gopkg.in/go-playground/webhooks.v5/github"
"regexp"
"strings"
"text/template"

"github.com/irccloud/irccat/util"

"gopkg.in/go-playground/webhooks.v5/github"
)

var defaultTemplates = map[string]string{
Expand Down Expand Up @@ -39,6 +42,11 @@ func refType(ref string) string {
return ""
}

func stripQuoteAndTruncate(in string, length int) string {
var quote = regexp.MustCompile(`>.*\\n`)
return util.Truncate(quote.ReplaceAllString(in, ""), length)
}

func truncateSha(sha string) string {
if len(sha) < 8 {
return ""
Expand All @@ -62,7 +70,7 @@ func highlightFormat(text string) string {
func parseTemplates() *template.Template {

funcMap := template.FuncMap{
"trunc": util.Truncate,
"trunc": stripQuoteAndTruncate,
"truncateSha": truncateSha,
"refType": refType,
"refName": refName,
Expand Down

0 comments on commit 094f069

Please sign in to comment.