diff --git a/Demo/Delphi/Demo.dproj b/Demo/Delphi/Demo.dproj index e6ff717..03c281d 100644 --- a/Demo/Delphi/Demo.dproj +++ b/Demo/Delphi/Demo.dproj @@ -1,7 +1,7 @@  {96F15591-1663-42C2-A827-5500EA134A38} - 19.5 + 20.1 VCL True Debug @@ -9,6 +9,7 @@ 1 Application Demo.dpr + Demo true @@ -216,6 +217,16 @@ 1 + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + res\values @@ -236,6 +247,66 @@ 1 + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + res\values @@ -246,6 +317,16 @@ 1 + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + res\drawable @@ -416,6 +497,56 @@ 1 + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + 1 @@ -656,6 +787,9 @@ 1 + + 1 + @@ -949,6 +1083,7 @@ + True diff --git a/Demo/Delphi/Demo.res b/Demo/Delphi/Demo.res index 2ef89a9..a0ce1ff 100644 Binary files a/Demo/Delphi/Demo.res and b/Demo/Delphi/Demo.res differ diff --git a/Demo/Delphi/Win32/Debug/.env-example b/Demo/Delphi/Win32/Debug/.env-example index 7a52e45..8dc8f08 100644 --- a/Demo/Delphi/Win32/Debug/.env-example +++ b/Demo/Delphi/Win32/Debug/.env-example @@ -4,4 +4,6 @@ MeuNome=Rafael Alves DB_USERNAME=${MeuNome}\Developer # teste Nome3=${MeuNome} - ${DB_USERNAME} - ${APPDATA} OK # teste poderoso Development=True -Port=3001 \ No newline at end of file +Port=3001 +DBPASSWORD=E#6vK7z +DBPASSWORD2=E#6vK7zXa # comentario \ No newline at end of file diff --git a/Demo/Delphi/uDemo.pas b/Demo/Delphi/uDemo.pas index 4065066..771b319 100644 --- a/Demo/Delphi/uDemo.pas +++ b/Demo/Delphi/uDemo.pas @@ -57,6 +57,9 @@ procedure TForm2.Button2Click(Sender: TObject); Memo1.Lines.Add(DotEnv.Env('MeuNome')); //Usando o nome da variável Memo1.Lines.Add(DotEnv.Env(DB_USERNAME)); //Usando o enumerado default (procura dentro do arquivo se há uma variável com o nome Memo1.Lines.Add(DotEnv.Env('Nome3')); + Memo1.Lines.Add(DotEnv.Env('DBPASSWORD2')); + Memo1.Lines.Add(DotEnv.DBPassword); + Memo1.Lines.Add(DotEnv.Env('Teste')); //Forma de Definir caminho do arquivo //DotEnv.Config('D:\Meus Projetos\DotEnv4Delphi\Demo\Win32\Debug\.env'); diff --git a/src/DotEnv4Delphi.pas b/src/DotEnv4Delphi.pas index d1697e3..157c997 100644 --- a/src/DotEnv4Delphi.pas +++ b/src/DotEnv4Delphi.pas @@ -136,7 +136,8 @@ TDotEnv4Delphi = class(TInterfacedObject, iDotEnv4Delphi) DotEnv: iDotEnv4Delphi; const - fVersion = '1.4.0'; //Const to manage versioning + fVersion = '1.5.0'; //Const to manage versioning + SingleQuote = #39; //Caracter ' //-------------------------------------------------------------------------------------------------------------------------- implementation @@ -193,22 +194,24 @@ procedure TDotEnv4Delphi.ReadEnvFile; var positionOfLastQuote: integer; begin - if (valor.StartsWith('"')) or (valor.StartsWith(#39)) then + if (valor.StartsWith('"')) or (valor.StartsWith(SingleQuote)) then begin positionOfLastQuote := Pos('"', Copy(valor, 2, length(valor) - 1)); if positionOfLastQuote = 0 then - positionOfLastQuote := Pos(#39, Copy(valor, 2, length(valor) - 1)); + positionOfLastQuote := Pos(SingleQuote, Copy(valor, 2, length(valor) - 1)); if positionOfLastQuote > 0 then begin - if Pos('#', valor) > positionOfLastQuote then - Result := Copy(valor, 1, Pos('#', valor) - 1); + if Pos('# ', valor) > positionOfLastQuote then + Result := Copy(valor, 1, Pos('# ', valor) - 2) + else + Result := valor; end; end else begin - if Pos('#', valor) > 0 then - Result := Copy(valor, 1, Pos('#', valor) - 1) + if Pos('# ', valor) > 0 then + Result := Copy(valor, 1, Pos('# ', valor) - 2) else Result := valor; end; @@ -220,7 +223,7 @@ procedure TDotEnv4Delphi.ReadEnvFile; chave, ValorChave: string; begin Result := valor; - if (not valor.StartsWith('"')) and (not valor.StartsWith(#39)) then + if (not valor.StartsWith('"')) and (not valor.StartsWith(SingleQuote)) then begin while Pos('${', Result) > 0 do begin @@ -237,16 +240,16 @@ procedure TDotEnv4Delphi.ReadEnvFile; var positionOfLastQuote: integer; begin - if (valor.StartsWith('"')) or (valor.StartsWith(#39)) then + if (valor.StartsWith('"')) or (valor.StartsWith(SingleQuote)) then begin positionOfLastQuote := Pos('"', Copy(valor, 2, length(valor) - 1)); if positionOfLastQuote = 0 then - positionOfLastQuote := Pos(#39, Copy(valor, 2, length(valor) - 1)); + positionOfLastQuote := Pos(SingleQuote, Copy(valor, 2, length(valor) - 1)); if positionOfLastQuote > 0 then begin Result := StringReplace(valor, '"', '', [rfReplaceAll]); - Result := StringReplace(valor, #39, '', [rfReplaceAll]); + Result := StringReplace(valor, SingleQuote, '', [rfReplaceAll]); end; end else