From 3c386bfe9eb5e13365db329bc3218be2d6754222 Mon Sep 17 00:00:00 2001 From: markpadbe Date: Mon, 28 Oct 2024 14:35:39 -0700 Subject: [PATCH] Fix useblock code issue --- libs/features/personalization/personalization.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 3ade3b3c00..0ff2920a50 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -239,18 +239,20 @@ const fetchData = async (url, type = DATA_TYPE.JSON) => { return null; }; -const getBlockProps = (fVal, miloLibs, origin) => { +const getBlockProps = (fVal, config, origin) => { let val = fVal; if (val?.includes('\\')) val = val?.split('\\').join('/'); if (!val?.startsWith('/')) val = `/${val}`; const blockSelector = val?.split('/').pop(); - if (!miloLibs) return { blockSelector, blockTarget: val }; if (val.startsWith('/libs/')) { /* c8 ignore next 1 */ - return { blockSelector, blockTarget: `${miloLibs}${val.replace('/libs', '')}` }; + val = `${config.miloLibs || config.codeRoot}${val.replace('/libs', '')}`; + } else { + val = `${origin}${val}`; } - return { blockSelector, blockTarget: `${origin}${val}` }; + + return { blockSelector, blockTarget: val }; }; const consolidateArray = (arr, prop, existing = []) => arr @@ -577,7 +579,7 @@ const getVariantInfo = (line, variantNames, variants, manifestPath, fTargetId) = variants[vn][action] = variants[vn][action] || []; if (action === 'useblockcode') { - const { blockSelector, blockTarget } = getBlockProps(line[vn], config.miloLibs, origin); + const { blockSelector, blockTarget } = getBlockProps(line[vn], config, origin); variants[vn][action].push({ selector: blockSelector, val: blockTarget,