Sfoglia il codice sorgente

nodejs: fixed GetEnvironmentVariable on non existing vars

mattias 6 anni fa
parent
commit
078502d94c
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      packages/fcl-base/nodejsapp.pas

+ 7 - 1
packages/fcl-base/nodejsapp.pas

@@ -63,8 +63,14 @@ begin
 end;
 
 function MyGetEnvironmentVariable(Const EnvVar: String): String;
+var
+  v: JSValue;
 begin
-  Result:=String(TNJSProcess.env[EnvVar]);
+  v:=TNJSProcess.env[EnvVar];
+  if isString(v) then
+    Result:=String(v)
+  else
+    Result:='';
 end;
 
 function MyGetEnvironmentVariableCount: Integer;