mirror of
https://github.com/zyachel/quetre.git
synced 2025-04-05 14:07:37 +03:00
fix(parse): don't bail out on encountering weird characters
replace all \x3C(<) with its valid unique escape sequence
This commit is contained in:
parent
1073e61530
commit
f11d3f2ac6
3 changed files with 18 additions and 8 deletions
11
utils/parse.js
Normal file
11
utils/parse.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue