From dc466fc76bde033d48af5fe89ffbd84bb7e194d3 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 25 May 2025 15:13:51 +0530 Subject: [PATCH] Fix quotes issue in `TrackLink` regexp. --- models/models.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/models.go b/models/models.go index 2f1d347b..8fb6c639 100644 --- a/models/models.go +++ b/models/models.go @@ -98,11 +98,11 @@ type regTplFunc struct { var regTplFuncs = []regTplFunc{ // Regular expression for matching {{ TrackLink "http://link.com" }} in the template - // and substituting it with {{ Track "http://link.com" . }} (the dot context) + // and substituting it with {{ TrackLink "http://link.com" . }} (the dot context) // before compilation. This is to make linking easier for users. { - regExp: regexp.MustCompile(`{{(\s+)?TrackLink(\s+)?(.+?)(\s+)?}}`), - replace: `{{ TrackLink $3 . }}`, + regExp: regexp.MustCompile(`{{\s*TrackLink\s+"([^"]+)"\s*}}`), + replace: `{{ TrackLink "$1" . }}`, }, // Convert the shorthand https://google.com@TrackLink to {{ TrackLink ... }}. @@ -543,6 +543,7 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error { for _, r := range regTplFuncs { body = r.regExp.ReplaceAllString(body, r.replace) } + baseTPL, err := template.New(BaseTpl).Funcs(f).Parse(body) if err != nil { return fmt.Errorf("error compiling base template: %v", err)