Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
fix(proxy): use the destination url when determining agent
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed May 24, 2017
1 parent b0b4d22 commit 1a714e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand All @@ -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')
}
Expand Down

0 comments on commit 1a714e7

Please sign in to comment.