Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getProxyForUrl(url) {
* @private
*/
function shouldProxy(hostname, port) {
var NO_PROXY =
var NO_PROXY = getEnv('npm_config_noproxy') ||
(getEnv('npm_config_no_proxy') || getEnv('no_proxy')).toLowerCase();
if (!NO_PROXY) {
return true; // Always proxy if NO_PROXY is not set.
Expand Down
13 changes: 13 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,18 @@ describe('getProxyForUrl', function() {
testProxyUrl(env, '', 'http://example');
testProxyUrl(env, 'http://proxy', 'http://otherwebsite');
});
// eslint-disable-next-line max-len
describe('npm_config_noproxy should take precedence over npm_config_no_proxy and NO_PROXY', function() {
var env = {};
env.HTTP_PROXY = 'http://proxy';
env.NO_PROXY = 'otherwebsite';
// eslint-disable-next-line camelcase
env.npm_config_no_proxy = 'anotherexample';
// eslint-disable-next-line camelcase
env.npm_config_noproxy = 'example';
testProxyUrl(env, '', 'http://example');
testProxyUrl(env, 'http://proxy', 'http://anotherexample');
testProxyUrl(env, 'http://proxy', 'http://otherwebsite');
});
});
});