quetre/utils/parse.js
zyachel f11d3f2ac6 fix(parse): don't bail out on encountering weird characters
replace all \x3C(<) with its valid unique escape sequence
2024-04-08 00:22:51 +05:30

11 lines
291 B
JavaScript

const invalidLessThan = /\\x3C/g;
const validLessThan = '\\u003C';
/**
* parses and corrects invalid escape sequences
* @param {string} data
* @returns {Record<PropertyKey, any>}
*/
const parse = data => JSON.parse(data.replace(invalidLessThan, validLessThan));
export default parse;