From 7db814c7ada34b4a03f1ff60c67d2a68b9139580 Mon Sep 17 00:00:00 2001 From: Phil Cullen <20287171+philipcullen@users.noreply.github.com> Date: Wed, 23 Oct 2019 17:46:19 +0100 Subject: [PATCH] fix: use global replace for analytics header templates (#1134) Support replacing multiple instances of the same template variable in analytics templates --- server/models/analytics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/models/analytics.js b/server/models/analytics.js index b6dd4d48..17a3f6ab 100644 --- a/server/models/analytics.js +++ b/server/models/analytics.js @@ -117,7 +117,7 @@ module.exports = class Analytics extends Model { code.bodyEnd = _.defaultTo(code.bodyEnd, '') _.forOwn(provider.config, (value, key) => { - code.head = _.replace(code.head, `{{${key}}}`, value) + code.head = _.replace(code.head, new RegExp(`{{${key}}}`, 'g'), value) code.bodyStart = _.replace(code.bodyStart, `{{${key}}}`, value) code.bodyEnd = _.replace(code.bodyEnd, `{{${key}}}`, value) })