File tree 1 file changed +15
-14
lines changed
components/gitpod-protocol/src
1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -293,21 +293,22 @@ export namespace EnvVar {
293
293
return res ;
294
294
}
295
295
296
- ( imageAuth . value || "" ) . split ( "," ) . forEach ( ( entry ) => {
297
- const parts = entry . trim ( ) . split ( ":" ) ;
298
- if ( parts . length === 2 ) {
299
- const [ host , token ] = parts ;
300
- if ( host && token ) {
301
- res . set ( host , token ) ;
302
- }
303
- } else if ( parts . length === 3 ) {
304
- const [ host , port , token ] = parts ;
305
- const hostWithPort = `${ host } :${ port } ` ;
306
- if ( hostWithPort && token ) {
307
- res . set ( hostWithPort , token ) ;
308
- }
296
+ // Returns a host value, which can include port, if token also has length.
297
+ const getHost = ( parts : string [ ] ) : string => {
298
+ if ( parts . length === 2 && parts [ 0 ] && parts [ 1 ] ) {
299
+ return parts [ 0 ] ;
300
+ } else if ( parts . length === 3 && parts [ 0 ] && parts [ 1 ] && parts [ 2 ] ) {
301
+ return `${ parts [ 0 ] } :${ parts [ 1 ] } ` ;
309
302
}
310
- } ) ;
303
+ return "" ;
304
+ } ;
305
+
306
+ ( imageAuth . value || "" )
307
+ . split ( "," )
308
+ . map ( ( e ) => e . trim ( ) . split ( ":" ) )
309
+ . forEach ( ( parts ) => {
310
+ getHost ( parts ) !== "" ? res . set ( getHost ( parts ) , parts [ parts . length - 1 ] ) : null ;
311
+ } ) ;
311
312
312
313
return res ;
313
314
}
You can’t perform that action at this time.
0 commit comments