Files
frontend-app-authn/src/recommendations/data/utils.js
Syed Sajjad Hussain Shah 81d69c8e72 feat: add optimizely exp for recommendations page (#754)
VAN-1294

Co-authored-by: Syed Sajjad  Hussain Shah <syed.sajjad@H7FKF7K6XD.local>
2023-02-27 15:39:08 +05:00

18 lines
552 B
JavaScript

export const convertCourseRunKeytoCourseKey = (courseRunKey) => {
if (!courseRunKey) {
return '';
}
const newKeyFormat = courseRunKey.includes('+');
if (newKeyFormat) {
const splitCourseRunKey = courseRunKey.split(':').slice(-1)[0];
const splitCourseKey = splitCourseRunKey.split('+').slice(0, 2);
return `${splitCourseKey[0]}+${splitCourseKey[1]}`;
}
const splitCourseKey = courseRunKey.split('/').slice(0, 2);
return `${splitCourseKey[0]}+${splitCourseKey[1]}`;
};
export default {
convertCourseRunKeytoCourseKey,
};