Skip to content

Commit

Permalink
ECC ENV refactor WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai committed Sep 26, 2024
1 parent 5708b23 commit 47125db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
21 changes: 0 additions & 21 deletions ecc/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,6 @@ export function decorateArea(area = document) {
});
}

function getECCEnv(miloConfig) {
const { env } = miloConfig;

if (env.name === 'prod') return 'prod';

if (env.name === 'stage') {
const { host, search } = window.location;
const usp = new URLSearchParams(search);
const eccEnv = usp.get('eccEnv');

if (eccEnv) return eccEnv;

if (host.startsWith('main--')) return 'prod';
if (host.startsWith('stage--') || host.startsWith('www.stage')) return 'stage';
if (host.startsWith('dev--') || host.startsWith('www.dev')) return 'dev';
}

// fallback to dev
return 'dev';
}

const locales = {
'': { ietf: 'en-US', tk: 'jdq5hay.css' },
br: { ietf: 'pt-BR', tk: 'inq1xob.css' },
Expand Down
14 changes: 14 additions & 0 deletions ecc/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ const { createTag } = await import(`${LIBS}/utils/utils.js`);

let secretCache = [];

export function getECCEnv() {
const { host, search } = window.location;
const usp = new URLSearchParams(search);
const eccEnv = usp.get('eccEnv');

if (eccEnv) return eccEnv;
if (host.startsWith('dev--') || host.startsWith('www.dev')) return 'dev';
if (host.startsWith('stage--') || host.startsWith('www.stage')) return 'stage';
if (host.startsWith('main--') || host.endsWith === 'adobe.com') return 'prod';

// fallback to dev
return 'dev';
}

export function getIcon(tag) {
const img = document.createElement('img');
img.className = `icon icon-${tag}`;
Expand Down

0 comments on commit 47125db

Please sign in to comment.