Skip to content

Commit

Permalink
Explicitly check for Live tier, rather than assuming it's every hostn…
Browse files Browse the repository at this point in the history
…ame that doesn't qualify as the Preview tier. Resolves #2
  • Loading branch information
Colin Gourlay committed Jun 8, 2020
1 parent 659421e commit 102eede
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@ export function getGeneration(): GENERATIONS | null {

// Tier detection
// * Tiers can be detected (depending on the generation) by matching unique hostnames
const IS_TIER_PREVIEW = (hostname =>
hostname.indexOf(
IS_GENERATION_PRESENTATION_LAYER
? 'preview.presentation-layer'
: 'nucwed.aus.aunty'
) > -1)(window.location.hostname);
const IS_TIER_LIVE = !IS_TIER_PREVIEW;

// Allow us to read the deteted tier
const HOSTNAME = window.location.hostname;
const isPartialInHostname = (partialHostname: string): boolean =>
HOSTNAME.indexOf(partialHostname) > -1;
const IS_TIER_PREVIEW = isPartialInHostname(
IS_GENERATION_PRESENTATION_LAYER
? 'preview.presentation-layer'
: 'nucwed.aus.aunty'
);
const IS_TIER_LIVE = !!['www.abc', 'mobile.abc', 'bigted.abc'].find(
isPartialInHostname
);

// Allow us to read the detected tier
export function getTier(): TIERS | null {
return IS_TIER_PREVIEW ? TIERS.PREVIEW : IS_TIER_LIVE ? TIERS.LIVE : null;
}
Expand Down

0 comments on commit 102eede

Please sign in to comment.