From 1a714e7b77b9d006f24dbde806ec1c5d9d177c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 23 May 2017 19:05:36 -0700 Subject: [PATCH] fix(proxy): use the destination url when determining agent --- agent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent.js b/agent.js index fb97208..94baf88 100644 --- a/agent.js +++ b/agent.js @@ -34,7 +34,7 @@ function getAgent (uri, opts) { } if (pxuri) { - const proxy = getProxy(pxuri, opts) + const proxy = getProxy(pxuri, parsedUri, opts) AGENT_CACHE.set(key, proxy) return proxy } @@ -120,7 +120,7 @@ function getProxyUri (uri, opts) { let HttpProxyAgent let HttpsProxyAgent let SocksProxyAgent -function getProxy (proxyUrl, opts) { +function getProxy (proxyUrl, destUrl, opts) { let popts = { host: proxyUrl.hostname, port: proxyUrl.port, @@ -134,14 +134,14 @@ function getProxy (proxyUrl, opts) { rejectUnauthorized: opts.strictSSL } - if (proxyUrl.protocol === 'http:') { + if (destUrl.protocol === 'http:') { if (!HttpProxyAgent) { HttpProxyAgent = require('http-proxy-agent') } return new HttpProxyAgent(popts) } - if (proxyUrl.protocol === 'https:') { + if (destUrl.protocol === 'https:') { if (!HttpsProxyAgent) { HttpsProxyAgent = require('https-proxy-agent') }