fix(utils): avoid to use default value for null in json-templates (#2165)

This commit is contained in:
Junyi 2023-07-03 06:25:53 +07:00 committed by GitHub
parent 677442c844
commit 71c62245ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,15 +92,20 @@ const parseString = (() => {
return matches.reduce((result, match, i) => {
const parameter = parameters[i];
let value = objectPath.get(context, parameter.key);
if (value == null) {
const type = typeof value;
if (type === 'undefined') {
if (typeof parameter.defaultValue === 'undefined') {
return value;
}
value = parameter.defaultValue;
}
if (typeof value === 'function') {
if (type === 'function') {
value = value();
}
if (typeof value === 'object') {
if (type === 'object') {
return value;
}