From bc62af9da286abe9c32de93cc265665bf6a7657a Mon Sep 17 00:00:00 2001 From: DanielCliftonGuardian <110032454+DanielCliftonGuardian@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:39:26 +0000 Subject: [PATCH] fix/asset-url-path --- dotcom-rendering/src/lib/assets.test.ts | 11 ++++++----- dotcom-rendering/src/lib/assets.ts | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dotcom-rendering/src/lib/assets.test.ts b/dotcom-rendering/src/lib/assets.test.ts index da813843b94..b3429b53f26 100644 --- a/dotcom-rendering/src/lib/assets.test.ts +++ b/dotcom-rendering/src/lib/assets.test.ts @@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs'; import { BUILD_VARIANT } from '../../webpack/bundles'; import { APPS_SCRIPT, + BASE_URL_DEV, decideAssetOrigin, getModulesBuild, getPathFromManifest, @@ -27,9 +28,9 @@ describe('decideAssetOrigin for stage', () => { ); }); it('DEV', () => { - expect(decideAssetOrigin('DEV')).toEqual('/'); - expect(decideAssetOrigin('dev')).toEqual('/'); - expect(decideAssetOrigin(undefined)).toEqual('/'); + expect(decideAssetOrigin('DEV')).toEqual(BASE_URL_DEV); + expect(decideAssetOrigin('dev')).toEqual(BASE_URL_DEV); + expect(decideAssetOrigin(undefined)).toEqual(BASE_URL_DEV); }); }); @@ -81,13 +82,13 @@ describe('getPathFromManifest', () => { it('returns correct hashed asset (1)', () => { expect(getPathFromManifest('client.web', '7305.client.web.js')).toBe( - '/assets/7305.client.web.8cdc05567d98ebd9f67e.js', + 'http://localhost:3030/assets/7305.client.web.8cdc05567d98ebd9f67e.js', ); }); it('returns correct hashed asset (2)', () => { expect(getPathFromManifest('client.web', '356.client.web.js')).toBe( - '/assets/356.client.web.0a1bbdf8c7a5e5826b7c.js', + 'http://localhost:3030/assets/356.client.web.0a1bbdf8c7a5e5826b7c.js', ); }); diff --git a/dotcom-rendering/src/lib/assets.ts b/dotcom-rendering/src/lib/assets.ts index 43c92234c61..010f4b1dced 100644 --- a/dotcom-rendering/src/lib/assets.ts +++ b/dotcom-rendering/src/lib/assets.ts @@ -9,10 +9,12 @@ interface AssetHash { [key: string]: string; } +export const BASE_URL_DEV = 'http://localhost:3030/'; + export type AssetOrigin = | 'https://assets.guim.co.uk/' | 'https://assets-code.guim.co.uk/' - | '/'; + | typeof BASE_URL_DEV; /** * Decides the url to use for fetching assets @@ -27,7 +29,7 @@ export const decideAssetOrigin = (stage: string | undefined): AssetOrigin => { case 'CODE': return 'https://assets-code.guim.co.uk/'; default: - return '/'; + return BASE_URL_DEV; } };