Skip to content

Commit

Permalink
Simplify amp iframe baseUrl logic
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 committed Sep 17, 2024
1 parent d9c3bce commit 4b84691
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/app/components/MediaLoader/utils/urlConstructors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getEnvConfig } from '#app/lib/utilities/getEnvConfig';
import isLive from '#app/lib/utilities/isLive';
import parseAvRoute from '#app/routes/utils/parseAvRoute';

Expand All @@ -7,20 +6,6 @@ const TEST_BASE_URL = 'https://www.test.bbc.com';

const LIVE_AMP_URL = 'https://web-cdn.api.bbci.co.uk';
const TEST_AMP_URL = 'https://web-cdn.test.api.bbci.co.uk';
const DEV_AMP_URL = TEST_AMP_URL;

const isDev = () => getEnvConfig().SIMORGH_APP_ENV === 'local';

const getAmpBaseUrl = () => {
switch (true) {
case isLive():
return LIVE_AMP_URL;
case isDev():
return DEV_AMP_URL;
default:
return TEST_AMP_URL;
}
};

type FuncProps = {
id: string | null;
Expand All @@ -33,7 +18,7 @@ export const getAmpIframeUrl = ({ id, versionID, lang }: FuncProps) => {

const { platform, service, variant, assetId } = parseAvRoute(id);

const ampBaseUrl = getAmpBaseUrl();
const ampBaseUrl = isLive() ? LIVE_AMP_URL : TEST_AMP_URL;

if (platform === 'cps') {
return `${ampBaseUrl}/ws/av-embeds/cps/${service}${variant ? `/${variant}` : ''}/${assetId}${versionID ? `/${versionID}` : ''}${lang ? `/${lang}` : ''}/amp`;
Expand Down

0 comments on commit 4b84691

Please sign in to comment.