File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -83,10 +83,16 @@ export function getAgent(
8383
8484 if ( proxy && shouldUseProxy ) {
8585 // tslint:disable-next-line variable-name
86- const Agent = isHttp
86+ let Agent = isHttp
8787 ? require ( 'http-proxy-agent' )
8888 : require ( 'https-proxy-agent' ) ;
8989
90+ if ( Agent . HttpsProxyAgent ) {
91+ Agent = Agent . HttpsProxyAgent ;
92+ } else if ( Agent . HttpProxyAgent ) {
93+ Agent = Agent . HttpProxyAgent ;
94+ }
95+
9096 const proxyOpts = { ...parse ( proxy ) , ...poolOptions } ;
9197 return new Agent ( proxyOpts ) ;
9298 }
Original file line number Diff line number Diff line change @@ -23,9 +23,16 @@ import * as sinon from 'sinon';
2323import { getAgent , pool } from '../src/agents' ;
2424
2525// eslint-disable-next-line @typescript-eslint/no-var-requires
26- const HttpProxyAgent = require ( 'http-proxy-agent' ) ;
26+ let HttpProxyAgent = require ( 'http-proxy-agent' ) ;
2727// eslint-disable-next-line @typescript-eslint/no-var-requires
28- const HttpsProxyAgent = require ( 'https-proxy-agent' ) ;
28+ let HttpsProxyAgent = require ( 'https-proxy-agent' ) ;
29+
30+ if ( HttpProxyAgent . HttpProxyAgent ) {
31+ HttpProxyAgent = HttpProxyAgent . HttpProxyAgent ;
32+ }
33+ if ( HttpsProxyAgent . HttpsProxyAgent ) {
34+ HttpsProxyAgent = HttpsProxyAgent . HttpsProxyAgent ;
35+ }
2936
3037describe ( 'agents' , ( ) => {
3138 const httpUri = 'http://example.com' ;
@@ -91,7 +98,7 @@ describe('agents', () => {
9198 const proxy = 'https://hello.there:8080' ;
9299 const proxyExpected = {
93100 hostname : 'hello.there' ,
94- port : 8080 ,
101+ port : ' 8080' ,
95102 protocol : 'https:' ,
96103 } ;
97104
You can’t perform that action at this time.
0 commit comments