fix: Improve handling of 'undefined' values in JSON parsing

This commit is contained in:
kangfenmao 2025-02-15 01:25:59 +08:00
parent 16feb49e9e
commit 9a6aad35b0
2 changed files with 3 additions and 7 deletions

View File

@ -103,10 +103,10 @@ export default abstract class BaseProvider {
}
if (param.type === 'json') {
const value = param.value as string
return {
...acc,
[param.name]: isJSON(value) ? parseJSON(value) : value
if (value === 'undefined') {
return { ...acc, [param.name]: undefined }
}
return { ...acc, [param.name]: isJSON(value) ? parseJSON(value) : value }
}
return {
...acc,

View File

@ -28,10 +28,6 @@ export function isJSON(str: any): boolean {
}
export function parseJSON(str: string) {
if (str === 'undefined') {
return undefined
}
try {
return JSON.parse(str)
} catch (e) {