diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index e92babfeb1..e40eebde40 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -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/')) { @@ -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 }); } diff --git a/test/features/personalization/personalization.test.js b/test/features/personalization/personalization.test.js index 44f7106e3e..30edf9e66b 100644 --- a/test/features/personalization/personalization.test.js +++ b/test/features/personalization/personalization.test.js @@ -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'; @@ -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 = {