Browse Source

nodejs: fixed GetEnvironmentVariable on non existing vars

mattias 6 years ago
parent
commit
45a382eef3
1 changed files with 7 additions and 1 deletions
  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;