Skip to content

Commit

Permalink
Fix useblock code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
markpadbe committed Oct 28, 2024
1 parent 0e83b83 commit 3c386bf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3c386bf

Please sign in to comment.