Skip to content

Commit

Permalink
fix: respect NO_PROXY environment variable (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmoore authored and gr2m committed Dec 2, 2017
1 parent 3c4ab02 commit 9c68105
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
@@ -1,6 +1,7 @@
'use strict'

var HttpsProxyAgent = require('https-proxy-agent')
var getProxyForUrl = require('proxy-from-env').getProxyForUrl
var toCamelCase = require('lodash/camelCase')
var urlTemplate = require('url-template')

Expand Down Expand Up @@ -619,7 +620,7 @@ var Client = module.exports = function (config) {
if (this.config.proxy !== undefined) {
proxyUrl = this.config.proxy
} else {
proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY
proxyUrl = getProxyForUrl(url)
}

// proxy options will be removed: https://github.com/octokit/node-github/issues/656
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -30,6 +30,7 @@
"dotenv": "^4.0.0",
"https-proxy-agent": "^2.1.0",
"lodash": "^4.17.4",
"proxy-from-env": "^1.0.0",
"url-template": "^2.0.8"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions test/integration/params-validations-test.js
Expand Up @@ -26,15 +26,16 @@ describe('params validations', () => {

it('request error', () => {
const github = new GitHub({
host: 'nope'
host: '127.0.0.1',
port: 8 // officially unassigned port. See https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
})

return github.orgs.get({org: 'foo'})

.catch(error => {
error.toJSON().should.deep.equal({
code: '500',
message: 'getaddrinfo ENOTFOUND nope nope:443',
message: 'connect ECONNREFUSED 127.0.0.1:8',
status: 'Internal Server Error'
})
})
Expand Down

0 comments on commit 9c68105

Please sign in to comment.