Skip to content

Commit dc466fc

Browse files
committed
Fix quotes issue in TrackLink regexp.
1 parent 70fe7cb commit dc466fc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

models/models.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ type regTplFunc struct {
9898

9999
var regTplFuncs = []regTplFunc{
100100
// Regular expression for matching {{ TrackLink "http://link.com" }} in the template
101-
// and substituting it with {{ Track "http://link.com" . }} (the dot context)
101+
// and substituting it with {{ TrackLink "http://link.com" . }} (the dot context)
102102
// before compilation. This is to make linking easier for users.
103103
{
104-
regExp: regexp.MustCompile(`{{(\s+)?TrackLink(\s+)?(.+?)(\s+)?}}`),
105-
replace: `{{ TrackLink $3 . }}`,
104+
regExp: regexp.MustCompile(`{{\s*TrackLink\s+"([^"]+)"\s*}}`),
105+
replace: `{{ TrackLink "$1" . }}`,
106106
},
107107

108108
// Convert the shorthand https://google.com@TrackLink to {{ TrackLink ... }}.
@@ -543,6 +543,7 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error {
543543
for _, r := range regTplFuncs {
544544
body = r.regExp.ReplaceAllString(body, r.replace)
545545
}
546+
546547
baseTPL, err := template.New(BaseTpl).Funcs(f).Parse(body)
547548
if err != nil {
548549
return fmt.Errorf("error compiling base template: %v", err)

0 commit comments

Comments
 (0)