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-168109: do not modify absolute path to a script hosted in DAM when using insertScript action #3708

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export const DATA_TYPE = {

const IN_BLOCK_SELECTOR_PREFIX = 'in-block:';

const isDamContent = (path) => path?.includes('/content/dam/');

export const normalizePath = (p, localize = true) => {
let path = p;

if (!path?.includes('/')) {
return path;
}
if (isDamContent(path) || !path?.includes('/')) return path;

const config = getConfig();
if (path.startsWith('https://www.adobe.com/federal/')) {
Expand Down Expand Up @@ -1195,7 +1195,7 @@ function sendTargetResponseAnalytics(failure, responseStart, timeoutLocal, messa
},
},
data:
{ _adobe_corpnew: { digitalData: { primaryEvent: { eventInfo: { eventName: val } } } } },
{ _adobe_corpnew: { digitalData: { primaryEvent: { eventInfo: { eventName: val } } } } },
});
}, { once: true });
}
Expand Down
9 changes: 8 additions & 1 deletion test/features/personalization/personalization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFile } from '@web/test-runner-commands';
import { assert, stub } from 'sinon';
import { getConfig, setConfig } from '../../../libs/utils/utils.js';
import {
handleFragmentCommand, applyPers, cleanAndSortManifestList,
handleFragmentCommand, applyPers, cleanAndSortManifestList, normalizePath,
init, matchGlob, createContent, combineMepSources, buildVariantInfo,
} from '../../../libs/features/personalization/personalization.js';
import mepSettings from './mepSettings.js';
Expand Down Expand Up @@ -90,6 +90,13 @@ describe('Functional Test', () => {
expect(document.querySelector('.custom-block-2')).to.be.null;
});

it('should not normalize absolute path to a script file, if the file is hosted in DAM', async () => {
const DAMpath = 'https://www.adobe.com/content/dam/cc/optimization/mwpw-168109/test.js';
const nonDAMpath = 'https://www.adobe.com/foo/test.js';
expect(normalizePath(DAMpath)).to.include('https://www.adobe.com');
expect(normalizePath(nonDAMpath)).to.not.include('https://www.adobe.com');
});

it('scheduled manifest should apply changes if active (bts)', async () => {
const config = getConfig();
config.mep = {
Expand Down
Loading