@@ -311,6 +311,24 @@ export default class BaseClass {
311311 this . config . stackEnvironment = this . config . deliveryToken ?. scope [ 0 ] ?. environments [ 0 ] ?. name ;
312312 }
313313
314+ /**
315+ * @method parseEnvVariablesString - Parse environment variables string into key-value pairs
316+ * Splits on first colon only to support values containing colons (e.g., URLs)
317+ *
318+ * @param {string } envString - Comma-separated string of key:value pairs
319+ * @return {* } {Array<{key: string, value: string}> }
320+ * @memberof BaseClass
321+ */
322+ private parseEnvVariablesString ( envString : string ) : Array < { key : string ; value : string } > {
323+ return map ( split ( envString , ',' ) , ( pair ) => {
324+ const trimmedPair = ( pair as string ) . trim ( ) ;
325+ const colonIndex = trimmedPair . indexOf ( ':' ) ;
326+ const key = colonIndex !== - 1 ? trimmedPair . substring ( 0 , colonIndex ) . trim ( ) : trimmedPair . trim ( ) ;
327+ const value = colonIndex !== - 1 ? trimmedPair . substring ( colonIndex + 1 ) . trim ( ) : '' ;
328+ return { key, value } ;
329+ } ) . filter ( ( { key } ) => key ) ;
330+ }
331+
314332 /**
315333 * @method promptForEnvValues - Prompt and get manual entry of environment variables
316334 *
@@ -330,15 +348,7 @@ export default class BaseClass {
330348 message :
331349 'Enter key and value with a colon between them, and use a comma(,) for the key-value pair. Format: <key1>:<value1>, <key2>:<value2> Ex: APP_ENV:prod, TEST_ENV:testVal' ,
332350 } )
333- . then ( ( variable ) => {
334- return map ( split ( variable as string , ',' ) , ( variable ) => {
335- let [ key , value ] = split ( variable as string , ':' ) ;
336- value = ( value || '' ) . trim ( ) ;
337- key = ( key || '' ) . trim ( ) ;
338-
339- return { key, value } ;
340- } ) . filter ( ( { key } ) => key ) ;
341- } ) ;
351+ . then ( ( variable ) => this . parseEnvVariablesString ( variable as string ) ) ;
342352
343353 envVariables . push ( ...variable ) ;
344354
@@ -356,13 +366,7 @@ export default class BaseClass {
356366 this . envVariables . push ( ...envVariables ) ;
357367 } else {
358368 if ( typeof this . config . envVariables === 'string' ) {
359- const variable = map ( split ( this . config . envVariables as string , ',' ) , ( variable ) => {
360- let [ key , value ] = split ( variable as string , ':' ) ;
361- value = ( value || '' ) . trim ( ) ;
362- key = ( key || '' ) . trim ( ) ;
363-
364- return { key, value } ;
365- } ) ;
369+ const variable = this . parseEnvVariablesString ( this . config . envVariables ) ;
366370 this . envVariables . push ( ...variable ) ;
367371 }
368372 }
0 commit comments