From 76f41439e9702c6459eea466e6e01b0a039d25e0 Mon Sep 17 00:00:00 2001 From: Diana Catalina Olarte Date: Thu, 15 Aug 2024 18:42:05 +1000 Subject: [PATCH] fix: apply getPath to PUBLIC_PATH to allow use with CDN --- src/data/constants/app.js | 7 ++++--- src/data/constants/app.test.js | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/data/constants/app.js b/src/data/constants/app.js index cd6236f7..d314bff2 100644 --- a/src/data/constants/app.js +++ b/src/data/constants/app.js @@ -1,4 +1,5 @@ -import { getConfig } from '@edx/frontend-platform'; +import { getConfig, getPath } from '@edx/frontend-platform'; -export const routePath = () => `${getConfig().PUBLIC_PATH}:courseId`; -export const locationId = () => decodeURIComponent(window.location.pathname).replace(getConfig().PUBLIC_PATH, ''); +const publicPath = getPath(getConfig().PUBLIC_PATH); +export const routePath = () => `${publicPath}:courseId`; +export const locationId = () => decodeURIComponent(window.location.pathname).replace(publicPath, ''); diff --git a/src/data/constants/app.test.js b/src/data/constants/app.test.js index 21908022..232dc623 100644 --- a/src/data/constants/app.test.js +++ b/src/data/constants/app.test.js @@ -6,6 +6,7 @@ jest.unmock('./app'); jest.mock('@edx/frontend-platform', () => { const PUBLIC_PATH = '/test-public-path/'; return { + ...jest.requireActual('@edx/frontend-platform'), getConfig: () => ({ PUBLIC_PATH }), PUBLIC_PATH, };