Skip to content

Commit

Permalink
cleaned template data
Browse files Browse the repository at this point in the history
  • Loading branch information
cea2aj committed May 7, 2021
1 parent b9f12a5 commit 51f5fac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hooks/templatedataformatter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const getCleanedJamboInjectedData = require('../static/webpack/getCleanedJamboInjectedData');

/**
* Formats the data sent to the handlebars templates during Jambo builds.
*
Expand Down Expand Up @@ -28,7 +29,7 @@ module.exports = function (pageMetadata, siteLevelAttributes, pageNameToConfig)
}
};
if (globalConfig.useJWT) {
return getSecuredTemplateData(templateData);
return getCleanedTemplateData(templateData);
}
return templateData;
}
Expand Down Expand Up @@ -56,12 +57,21 @@ function getLocalizedGlobalConfig(globalConfig, currentLocaleConfig, locale) {
return localizedGlobalConfig;
}

function getSecuredTemplateData(templateData) {
/**
* Returns the provided template data without the API Key
*
* @param {Object} templateData
* @returns {Object}
*/
function getCleanedTemplateData(templateData) {
const jamboInjectedData = templateData.env.JAMBO_INJECTED_DATA;
const globalConfig = templateData.global_config;
return {
...templateData,
global_config: Object.assign({}, globalConfig, { apiKey: undefined }),
global_config: {
...globalConfig,
apiKey: undefined
},
env: {
JAMBO_INJECTED_DATA: getCleanedJamboInjectedData(jamboInjectedData)
}
Expand Down

0 comments on commit 51f5fac

Please sign in to comment.