File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -79,14 +79,27 @@ async function main() {
7979 process . exit ( 1 ) ;
8080 }
8181
82+ // Sanitize environment variable value by removing surrounding quotes
83+ const sanitizeEnvValue = ( value : string ) : string => {
84+ const trimmed = value . trim ( ) ;
85+ // Remove surrounding quotes (single or double) if present
86+ if (
87+ ( trimmed . startsWith ( '"' ) && trimmed . endsWith ( '"' ) ) ||
88+ ( trimmed . startsWith ( "'" ) && trimmed . endsWith ( "'" ) )
89+ ) {
90+ return trimmed . slice ( 1 , - 1 ) ;
91+ }
92+ return trimmed ;
93+ } ;
94+
8295 // Read and parse .env file
8396 const envContent = await readFile ( envPath , "utf-8" ) ;
8497 const envVars : Record < string , string > = { } ;
8598
8699 envContent . split ( "\n" ) . forEach ( ( line ) => {
87100 const [ key , value ] = line . split ( "=" ) ;
88101 if ( key && value && ! key . startsWith ( "#" ) ) {
89- envVars [ key . trim ( ) ] = value . trim ( ) ;
102+ envVars [ key . trim ( ) ] = sanitizeEnvValue ( value ) ;
90103 }
91104 } ) ;
92105
You can’t perform that action at this time.
0 commit comments