feat: 只处理 'formatter' key 为函数结构,防止错误字段解析

This commit is contained in:
奔跑的面条 2024-08-29 22:13:04 +08:00
parent 2201c09219
commit 0a12357997

View File

@ -324,13 +324,17 @@ export const evalFn = (fn: string) => {
* @param data
*/
export const JSONParse = (data: string) => {
if (data.trim() === '') return
return JSON.parse(data, (k, v) => {
// 过滤函数字符串
if (excludeParseEventKeyList.includes(k)) return v
// 过滤函数值表达式
if (typeof v === 'string') {
const someValue = excludeParseEventValueList.some(excludeValue => v.indexOf(excludeValue) > -1)
if (someValue) return v
// // 过滤函数字符串
// if (excludeParseEventKeyList.includes(k)) return v
// // 过滤函数值表达式
// if (typeof v === 'string') {
// const someValue = excludeParseEventValueList.some(excludeValue => v.indexOf(excludeValue) > -1)
// if (someValue) return v
// }
if (k !== 'formatter') {
return v
}
// 还原函数值
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {