Sfoglia il codice sorgente

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` }}
Kailash Nadh 6 anni fa
parent
commit
1fd3a3bada
2 ha cambiato i file con 2 aggiunte e 3 eliminazioni
  1. 0 1
      manager/manager.go
  2. 2 2
      models/models.go

+ 0 - 1
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.

+ 2 - 2
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 }}`