debian-mirror-gitlab/app/assets/javascripts/issue_show/utils/parse_data.js

28 lines
742 B
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import * as Sentry from '~/sentry/wrapper';
import { sanitize } from '~/lib/dompurify';
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
// We currently load + parse the data from the issue app and related merge request
let cachedParsedData;
2019-07-07 11:18:12 +05:30
export const parseIssuableData = () => {
try {
2020-11-24 15:15:51 +05:30
if (cachedParsedData) return cachedParsedData;
2021-01-03 14:25:43 +05:30
const initialDataEl = document.getElementById('js-issuable-app');
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
const parsedData = JSON.parse(initialDataEl.dataset.initial);
2020-11-24 15:15:51 +05:30
parsedData.initialTitleHtml = sanitize(parsedData.initialTitleHtml);
parsedData.initialDescriptionHtml = sanitize(parsedData.initialDescriptionHtml);
cachedParsedData = parsedData;
return parsedData;
2019-07-07 11:18:12 +05:30
} catch (e) {
2021-01-03 14:25:43 +05:30
Sentry.captureException(e);
2019-07-07 11:18:12 +05:30
return {};
}
};
export default {};