From 71c62245ad83c9b292b289402850573ad6b7c222 Mon Sep 17 00:00:00 2001 From: Junyi Date: Mon, 3 Jul 2023 06:25:53 +0700 Subject: [PATCH] fix(utils): avoid to use default value for null in json-templates (#2165) --- packages/core/utils/src/json-templates.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/core/utils/src/json-templates.ts b/packages/core/utils/src/json-templates.ts index 0315462df..00de502ea 100644 --- a/packages/core/utils/src/json-templates.ts +++ b/packages/core/utils/src/json-templates.ts @@ -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; }