Bugfixing.
This commit is contained in:
parent
86efa11994
commit
5670d21e76
31 changed files with 241 additions and 216 deletions
12
lib/tools.js
12
lib/tools.js
|
@ -108,16 +108,16 @@ function validateEmailGetMessage(result, address) {
|
|||
function formatMessage(campaign, list, subscription, mergeTags, message, filter, isHTML) {
|
||||
filter = typeof filter === 'function' ? filter : (str => str);
|
||||
|
||||
let links = getMessageLinks(campaign, list, subscription);
|
||||
const links = getMessageLinks(campaign, list, subscription);
|
||||
|
||||
let getValue = key => {
|
||||
const getValue = key => {
|
||||
key = (key || '').toString().toUpperCase().trim();
|
||||
if (links.hasOwnProperty(key)) {
|
||||
return links[key];
|
||||
}
|
||||
if (mergeTags.hasOwnProperty(key)) {
|
||||
let value = (mergeTags[key] || '').toString();
|
||||
let containsHTML = /<[a-z][\s\S]*>/.test(value);
|
||||
const value = (mergeTags[key] || '').toString();
|
||||
const containsHTML = /<[a-z][\s\S]*>/.test(value);
|
||||
return isHTML ? he.encode((containsHTML ? value : value.replace(/(?:\r\n|\r|\n)/g, '<br/>')), {
|
||||
useNamedReferences: true,
|
||||
allowUnsafeSymbols: true
|
||||
|
@ -127,7 +127,6 @@ function formatMessage(campaign, list, subscription, mergeTags, message, filter,
|
|||
};
|
||||
|
||||
return message.replace(/\[([a-z0-9_]+)(?:\/([^\]]+))?\]/ig, (match, identifier, fallback) => {
|
||||
identifier = identifier.toUpperCase();
|
||||
let value = getValue(identifier);
|
||||
if (value === false) {
|
||||
return match;
|
||||
|
@ -189,6 +188,7 @@ module.exports = {
|
|||
mergeTemplateIntoLayout,
|
||||
getTemplate,
|
||||
prepareHtml,
|
||||
getMessageLinks
|
||||
getMessageLinks,
|
||||
formatMessage
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue