fix: correct internal routing
The Content dropdown items have incorrect URLs for the internal routing when MFEs are deployed using the common domain and the PUBLIC_PATH.
This commit is contained in:
committed by
Adolfo R. Brandes
parent
4395607074
commit
3607e6423d
42
src/utils.js
42
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 = getPath(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}`;
|
||||
}
|
||||
@@ -268,22 +287,3 @@ export const getFileSizeToClosestByte = (fileSize) => {
|
||||
const fileSizeFixedDecimal = Number.parseFloat(size).toFixed(2);
|
||||
return `${fileSizeFixedDecimal} ${units[divides]}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 = getPath(getConfig().PUBLIC_PATH);
|
||||
|
||||
if (basePath.endsWith('/')) {
|
||||
basePath = basePath.slice(0, -1);
|
||||
}
|
||||
|
||||
if (!checkPath.startsWith(basePath)) {
|
||||
return `${basePath}${checkPath}`;
|
||||
}
|
||||
|
||||
return checkPath;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user