Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-161871 [MEP] useblockcode action fails if page is on milo site #3161

Merged
merged 14 commits into from
Nov 8, 2024
6 changes: 3 additions & 3 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ 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 (val.startsWith('/libs/')) {
/* c8 ignore next 1 */
val = `${miloLibs}${val.replace('/libs', '')}`;
val = `${config.miloLibs || config.codeRoot}${val.replace('/libs', '')}`;
} else {
val = `${origin}${val}`;
}
Expand Down Expand Up @@ -593,7 +593,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
Loading