@@ -1378,12 +1378,12 @@ export default defineComponent({
13781378 },
13791379 ],
13801380 takenDomains: [] as string [],
1381- advanced: localStorage .getItem (' kubero-advanced-app-config' ) === ' true' ,
1381+ advanced: localStorage .getItem (" kubero-advanced-app-config" ) === " true" ,
13821382 panel: [0 ],
13831383 valid: false ,
13841384 sleep: " disabled" ,
13851385 sleepEnabled: false ,
1386- envFile: [] ,
1386+ envFile: null as File | null ,
13871387 buildpacks: [] as { text: string ; value: Buildpack }[],
13881388 basicAuth: {
13891389 enabled: false ,
@@ -1724,7 +1724,7 @@ export default defineComponent({
17241724 },
17251725 watch: {
17261726 advanced(newValue ) {
1727- localStorage .setItem (' kubero-advanced-app-config' , newValue .toString ());
1727+ localStorage .setItem (" kubero-advanced-app-config" , newValue .toString ());
17281728 },
17291729 },
17301730 async mounted() {
@@ -2516,28 +2516,65 @@ export default defineComponent({
25162516 }
25172517 },
25182518 handleFileInput() {
2519- for (let i = 0 ; i < this .envFile .length ; i ++ ) {
2520- const file = this .envFile [i ];
2519+ // check if the file is an array or not
2520+ let envFiles = [] as File [];
2521+ if (! Array .isArray (this .envFile ) && this .envFile ) {
2522+ envFiles = [this .envFile ];
2523+ }
2524+
2525+ for (let i = 0 ; i < envFiles .length ; i ++ ) {
2526+ const file = envFiles [i ];
2527+
2528+ // Validate file type
2529+ if (! file .name ?.endsWith (" .env" ) && ! file .name .endsWith (" .txt" )) {
2530+ console .warn (
2531+ ` Skipping file ${file .name }: Expected .env or .txt file `
2532+ );
2533+ continue ;
2534+ }
2535+
25212536 const reader = new FileReader ();
25222537 reader .onload = () => {
2523- const text = reader .result ;
2524- this .parseEnvFile (text );
2538+ try {
2539+ const text = reader .result as string ;
2540+ this .parseEnvFile (text );
2541+ } catch (error ) {
2542+ console .error (" Error parsing env file:" , error );
2543+ }
2544+ };
2545+
2546+ reader .onerror = () => {
2547+ console .error (` Error reading file ${file .name } ` );
25252548 };
2549+
25262550 reader .readAsText (file );
25272551 }
25282552
25292553 // clear file input
2530- this .envFile = [] ;
2554+ this .envFile = null ;
25312555 },
25322556 parseEnvFile(text : any ) {
25332557 const lines = text .split (" \n " );
25342558 for (const line of lines ) {
2535- const [name, value] = line .split (" =" );
2536- // check if name isn't commented out
2537- if (name && ! name .startsWith (" #" ) && value ) {
2538- if (! this .envVars .some ((envVars ) => envVars .name === name .trim ())) {
2539- this .envVars .push ({ name: name .trim (), value: value .trim () });
2540- }
2559+ const trimmedLine = line .trim ();
2560+ // Skip empty lines and comments
2561+ if (! trimmedLine || trimmedLine .startsWith (" #" )) {
2562+ continue ;
2563+ }
2564+
2565+ const equalIndex = trimmedLine .indexOf (" =" );
2566+ if (equalIndex === - 1 ) {
2567+ continue ; // Skip lines without =
2568+ }
2569+
2570+ const name = trimmedLine .substring (0 , equalIndex ).trim ();
2571+ const value = trimmedLine .substring (equalIndex + 1 ).trim ();
2572+
2573+ // Remove quotes if present
2574+ const cleanValue = value .replace (/ ^ ["'] | ["'] $ / g , " " );
2575+
2576+ if (name && ! this .envVars .some ((envVar ) => envVar .name === name )) {
2577+ this .envVars .push ({ name , value: cleanValue });
25412578 }
25422579 }
25432580 },
0 commit comments