@@ -62,7 +62,7 @@ module.exports = class Agent extends AgentBase {
6262
6363 let ProxyAgent = this . #ProxyAgent
6464 if ( Array . isArray ( ProxyAgent ) ) {
65- ProxyAgent = options . secureEndpoint ? ProxyAgent [ 1 ] : ProxyAgent [ 0 ]
65+ ProxyAgent = this . isSecureEndpoint ( options ) ? ProxyAgent [ 1 ] : ProxyAgent [ 0 ]
6666 }
6767
6868 const proxyAgent = new ProxyAgent ( proxy , this . #options)
@@ -106,6 +106,7 @@ module.exports = class Agent extends AgentBase {
106106
107107 let socket
108108 let timeout = this . #timeouts. connection
109+ const isSecureEndpoint = this . isSecureEndpoint ( options )
109110
110111 const proxy = this . #getProxy( options )
111112 if ( proxy ) {
@@ -124,7 +125,7 @@ module.exports = class Agent extends AgentBase {
124125 timeout = timeout - ( Date . now ( ) - start )
125126 }
126127 } else {
127- socket = ( options . secureEndpoint ? tls : net ) . connect ( options )
128+ socket = ( isSecureEndpoint ? tls : net ) . connect ( options )
128129 }
129130
130131 socket . setKeepAlive ( this . keepAlive , this . keepAliveMsecs )
@@ -133,8 +134,8 @@ module.exports = class Agent extends AgentBase {
133134 const abortController = new AbortController ( )
134135 const { signal } = abortController
135136
136- const connectPromise = socket [ options . secureEndpoint ? 'secureConnecting' : 'connecting' ]
137- ? once ( socket , options . secureEndpoint ? 'secureConnect' : 'connect' , { signal } )
137+ const connectPromise = socket [ isSecureEndpoint ? 'secureConnecting' : 'connecting' ]
138+ ? once ( socket , isSecureEndpoint ? 'secureConnect' : 'connect' , { signal } )
138139 : Promise . resolve ( )
139140
140141 await this . #timeoutConnection( {
0 commit comments