2020-10-13 06:09:09 +00:00
|
|
|
import * as Sentry from '~/sentry/wrapper';
|
2020-09-23 06:09:45 +00:00
|
|
|
import { sanitize } from '~/lib/dompurify';
|
2019-04-05 00:15:56 +00:00
|
|
|
|
2020-09-14 12:09:34 +00:00
|
|
|
// We currently load + parse the data from the issue app and related merge request
|
|
|
|
let cachedParsedData;
|
|
|
|
|
2019-04-05 00:15:56 +00:00
|
|
|
export const parseIssuableData = () => {
|
|
|
|
try {
|
2020-09-14 12:09:34 +00:00
|
|
|
if (cachedParsedData) return cachedParsedData;
|
|
|
|
|
2020-09-25 06:09:42 +00:00
|
|
|
const initialDataEl = document.getElementById('js-issuable-app');
|
2020-09-02 18:10:40 +00:00
|
|
|
|
2020-09-25 06:09:42 +00:00
|
|
|
const parsedData = JSON.parse(initialDataEl.dataset.initial);
|
2020-09-02 18:10:40 +00:00
|
|
|
parsedData.initialTitleHtml = sanitize(parsedData.initialTitleHtml);
|
|
|
|
parsedData.initialDescriptionHtml = sanitize(parsedData.initialDescriptionHtml);
|
|
|
|
|
2020-09-14 12:09:34 +00:00
|
|
|
cachedParsedData = parsedData;
|
|
|
|
|
2020-09-02 18:10:40 +00:00
|
|
|
return parsedData;
|
2019-04-05 00:15:56 +00:00
|
|
|
} catch (e) {
|
2020-09-25 06:09:42 +00:00
|
|
|
Sentry.captureException(e);
|
2019-04-05 00:15:56 +00:00
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {};
|