fix: correct internal routes
The Content dropdown items have incorrect URLs for the internal routing when MFEs are deployed using the common domain and the PUBLIC_PATH. Introduce the new function to check the path correctness ( it already exists in master) and wrap the navigational links with it.
This commit is contained in:
committed by
Adolfo R. Brandes
parent
2b8edfd761
commit
74ce163bec
23
src/utils.js
23
src/utils.js
@@ -95,12 +95,31 @@ export function parseArrayOrObjectValues(obj) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a correct inner path depend on config PUBLIC_PATH.
|
||||
* @param {string} checkPath - the internal route path that is validated
|
||||
* @returns {string} - the correct internal route path
|
||||
*/
|
||||
export const createCorrectInternalRoute = (checkPath) => {
|
||||
let basePath = getConfig().PUBLIC_PATH;
|
||||
|
||||
if (basePath.endsWith('/')) {
|
||||
basePath = basePath.slice(0, -1);
|
||||
}
|
||||
|
||||
if (!checkPath.startsWith(basePath)) {
|
||||
return `${basePath}${checkPath}`;
|
||||
}
|
||||
|
||||
return checkPath;
|
||||
};
|
||||
|
||||
export function getPagePath(courseId, isMfePageEnabled, urlParameter) {
|
||||
if (isMfePageEnabled === 'true') {
|
||||
if (urlParameter === 'tabs') {
|
||||
return `${getConfig().BASE_URL}/course/${courseId}/pages-and-resources`;
|
||||
return createCorrectInternalRoute(`/course/${courseId}/pages-and-resources`);
|
||||
}
|
||||
return `${getConfig().BASE_URL}/course/${courseId}/${urlParameter}`;
|
||||
return createCorrectInternalRoute(`/course/${courseId}/${urlParameter}`);
|
||||
}
|
||||
return `${getConfig().STUDIO_BASE_URL}/${urlParameter}/${courseId}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user