Skip to content

Commit

Permalink
Update utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
TsayAdobe committed Dec 18, 2024
1 parent c0e2d62 commit 2c7ae36
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions acrobat/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ export const [setLibs, getLibs] = (() => {
(prodLibs, location) => {
libs = (() => {
const { hostname, search } = location || window.location;
if (!/\.hlx\.|\.aem\.|local|stage/.test(hostname)) return prodLibs;
// eslint-disable-next-line compat/compat
const branch = new URLSearchParams(search).get('milolibs') || 'main';
if (branch === 'main' && hostname === 'www.stage.adobe.com') return '/libs';
if (!/(\.hlx\.|\.aem\.|local|stage)/.test(hostname)) return prodLibs;
if (branch === 'local') return 'http://localhost:6456/libs';
return branch.includes('--') ? `https://${branch}.aem.live/libs` : `https://${branch}--milo--adobecom.aem.live/libs`;
const env = hostname.includes('.hlx.') ? 'hlx' : 'aem';
return `https://${branch}${branch.includes('--') ? '' : '--milo--adobecom'}.${env}.live/libs`;
})();
return libs;
}, () => libs,
];
})();

export function getEnv() {
const prodHosts = ['www.adobe.com', 'sign.ing', 'edit.ing'];
const stageHosts = [
const { hostname } = window.location;
if (['www.adobe.com', 'sign.ing', 'edit.ing'].includes(hostname)) return 'prod';
if ([
'stage--dc--adobecom.hlx.page', 'main--dc--adobecom.hlx.page',
'stage--dc--adobecom.hlx.live', 'main--dc--adobecom.hlx.live',
'stage--dc--adobecom.aem.page', 'main--dc--adobecom.aem.page',
'stage--dc--adobecom.aem.live', 'main--dc--adobecom.aem.live',
'www.stage.adobe.com',
];

if (prodHosts.includes(window.location.hostname)) return 'prod';
if (stageHosts.includes(window.location.hostname)) return 'stage';
].includes(hostname)) return 'stage';
return 'dev';
}

Expand Down

0 comments on commit 2c7ae36

Please sign in to comment.