fix(utils): avoid to use default value for null in json-templates (#2165)
This commit is contained in:
parent
677442c844
commit
71c62245ad
@ -92,15 +92,20 @@ const parseString = (() => {
|
|||||||
return matches.reduce((result, match, i) => {
|
return matches.reduce((result, match, i) => {
|
||||||
const parameter = parameters[i];
|
const parameter = parameters[i];
|
||||||
let value = objectPath.get(context, parameter.key);
|
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;
|
value = parameter.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'function') {
|
if (type === 'function') {
|
||||||
value = value();
|
value = value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'object') {
|
if (type === 'object') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user