debian-mirror-gitlab/app/assets/javascripts/issue_show/utils/parse_data.js
2020-11-24 15:15:51 +05:30

27 lines
750 B
JavaScript

import { sanitize } from 'dompurify';
// We currently load + parse the data from the issue app and related merge request
let cachedParsedData;
export const parseIssuableData = () => {
try {
if (cachedParsedData) return cachedParsedData;
const initialDataEl = document.getElementById('js-issuable-app-initial-data');
const parsedData = JSON.parse(initialDataEl.textContent.replace(/"/g, '"'));
parsedData.initialTitleHtml = sanitize(parsedData.initialTitleHtml);
parsedData.initialDescriptionHtml = sanitize(parsedData.initialDescriptionHtml);
cachedParsedData = parsedData;
return parsedData;
} catch (e) {
console.error(e); // eslint-disable-line no-console
return {};
}
};
export default {};