From 1fd3a3bada2ce11ef62cb819be03cd316192da6d Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 19 Dec 2018 12:28:52 +0530 Subject: [PATCH] Refactor TrackLink template function to accept backticks Quill link dialog (righly) escapes quotes in URL values there by breaking the TrackLink() template function. That is, {{ TrackLink "https://listmonk.app" }} when inserted using the Quill link dialog would become {{ TrackLink "https://listmonk.app" }}. A simplework around is to add support to backticks so that the template parser works with {{ TrackLink `https://listmonk.app` }} --- manager/manager.go | 1 - models/models.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manager/manager.go b/manager/manager.go index 6943ee2..34b540c 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -223,7 +223,6 @@ func (m *Manager) Run(tick time.Duration) { m.sendNotif(newC, newC.Status, "") } } - } // SpawnWorkers spawns workers goroutines that push out messages. diff --git a/models/models.go b/models/models.go index ff19a54..53e1798 100644 --- a/models/models.go +++ b/models/models.go @@ -51,8 +51,8 @@ const ( // and substituting it with {{ Track "http://link.com" .Campaign.UUID .Subscriber.UUID }} // before compilation. This string gimmick is to make linking easier for users. var ( - regexpLinkTag = regexp.MustCompile(`{{(\s+)?TrackLink\s+?"(.+?)"(\s+)?}}`) - regexpLinkTagReplace = `{{ TrackLink "$2" .Campaign.UUID .Subscriber.UUID }}` + regexpLinkTag = regexp.MustCompile("{{(\\s+)?TrackLink\\s+?(\"|`)(.+?)(\"|`)(\\s+)?}}") + regexpLinkTagReplace = `{{ TrackLink "$3" .Campaign.UUID .Subscriber.UUID }}` regexpViewTag = regexp.MustCompile(`{{(\s+)?TrackView(\s+)?}}`) regexpViewTagReplace = `{{ TrackView .Campaign.UUID .Subscriber.UUID }}`