Skip to content

Commit

Permalink
MWPW-168109: do not modify absolute path to a script hosted in DAM wh…
Browse files Browse the repository at this point in the history
…en using insertScript action
  • Loading branch information
Denys Fedotov authored and Denys Fedotov committed Feb 19, 2025
1 parent 87ac4b1 commit 7dd656e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ 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;

// do not change(normalize) DAM content link's domain, since DAM content links are PROD only
if (isDamContent(path)) return path;

if (!path?.includes('/')) {
return path;
}
Expand Down Expand Up @@ -1195,7 +1200,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 (later) 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

0 comments on commit 7dd656e

Please sign in to comment.