From 595fa907e64ae4e3a2fb6cfe5ec30caeca3dfd8b Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Fri, 13 Sep 2024 09:48:12 +0200 Subject: [PATCH] Improved dotEnv parse of boolean value. (yes,1,true,no,0,false) --- sources/MVCFramework.DotEnv.pas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sources/MVCFramework.DotEnv.pas b/sources/MVCFramework.DotEnv.pas index cc83fd33..391cf86f 100644 --- a/sources/MVCFramework.DotEnv.pas +++ b/sources/MVCFramework.DotEnv.pas @@ -346,7 +346,16 @@ begin end else begin - if not TryStrToBool(lTmp.Trim, Result) then + lTmp := lTmp.Trim.ToLower; + if (lTmp = 'yes') or (lTmp='1') or (lTmp='true') then + begin + Exit(True); + end; + if (lTmp = 'no') or (lTmp='0') or (lTmp='false') then + begin + Exit(False); + end; + if not TryStrToBool(lTmp, Result) then begin raise EMVCDotEnv.CreateFmt('Env "%s" is not a valid boolean [Current Value: "%s"]', [Name, lTmp]); end;