fix(utils): fix json-template type checking logic (#2177)
This commit is contained in:
parent
46294692dd
commit
637ccb0457
@ -92,20 +92,21 @@ 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);
|
||||||
const type = typeof value;
|
|
||||||
|
|
||||||
if (type === 'undefined') {
|
if (typeof value === 'undefined') {
|
||||||
if (typeof parameter.defaultValue === 'undefined') {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
value = parameter.defaultValue;
|
value = parameter.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'function') {
|
if (typeof value === 'function') {
|
||||||
value = value();
|
value = value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'object') {
|
if (typeof value === 'object' && value !== null) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accommodate numbers as values.
|
||||||
|
if (matches.length === 1 && str.startsWith('{{') && str.endsWith('}}')) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user