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 (#3708)

* MWPW-168109: do not modify absolute path to a script hosted in DAM when using insertScript action

* wording change

* Update libs/features/personalization/personalization.js

Co-authored-by: Vivian A Goodrich <[email protected]>

---------

Co-authored-by: Denys Fedotov <[email protected]>
Co-authored-by: Vivian A Goodrich <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2025
1 parent 87ac4b1 commit df33b42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
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

0 comments on commit df33b42

Please sign in to comment.