Socket
Socket
Sign inDemoInstall

proxy-from-env

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

.eslintrc

9

index.js

@@ -42,3 +42,7 @@ 'use strict';

var proxy = getEnv(proto + '_proxy') || getEnv('all_proxy');
var proxy =
getEnv('npm_config_' + proto + '_proxy') ||
getEnv(proto + '_proxy') ||
getEnv('npm_config_proxy') ||
getEnv('all_proxy');
if (proxy && proxy.indexOf('://') === -1) {

@@ -60,3 +64,4 @@ // Missing scheme in proxy, default to the requested URL's scheme.

function shouldProxy(hostname, port) {
var NO_PROXY = getEnv('no_proxy').toLowerCase();
var NO_PROXY =
(getEnv('npm_config_no_proxy') || getEnv('no_proxy')).toLowerCase();
if (!NO_PROXY) {

@@ -63,0 +68,0 @@ return true; // Always proxy if NO_PROXY is not set.

{
"name": "proxy-from-env",
"version": "1.0.0",
"version": "1.1.0",
"description": "Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.",
"main": "index.js",
"scripts": {
"lint": "jscs *.js && jshint *.js",
"lint": "eslint *.js",
"test": "mocha ./test.js --reporter spec",

@@ -29,8 +29,7 @@ "test-coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec"

"devDependencies": {
"coveralls": "^2.11.6",
"istanbul": "^0.4.2",
"jscs": "^2.10.1",
"jshint": "^2.9.1",
"mocha": "^2.4.5"
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"istanbul": "^0.4.5",
"mocha": "^7.1.0"
}
}

@@ -1,2 +0,2 @@

/* jshint mocha:true */
/* eslint max-statements:0 */
'use strict';

@@ -96,5 +96,4 @@

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
// eslint-disable-next-line camelcase
env.http_proxy = 'http://priority';
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
testProxyUrl(env, 'http://priority', 'http://example');

@@ -127,5 +126,4 @@ });

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
// eslint-disable-next-line camelcase
env.https_proxy = 'http://priority';
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
testProxyUrl(env, 'http://priority', 'https://example');

@@ -148,5 +146,4 @@ });

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
// eslint-disable-next-line camelcase
env.all_proxy = 'http://priority';
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
testProxyUrl(env, 'http://priority', 'https://example');

@@ -396,2 +393,95 @@ });

});
describe('NPM proxy configuration', function() {
describe('npm_config_http_proxy should work', function() {
var env = {};
// eslint-disable-next-line camelcase
env.npm_config_http_proxy = 'http://http-proxy';
testProxyUrl(env, '', 'https://example');
testProxyUrl(env, 'http://http-proxy', 'http://example');
// eslint-disable-next-line camelcase
env.npm_config_http_proxy = 'http://priority';
testProxyUrl(env, 'http://priority', 'http://example');
});
// eslint-disable-next-line max-len
describe('npm_config_http_proxy should take precedence over HTTP_PROXY and npm_config_proxy', function() {
var env = {};
// eslint-disable-next-line camelcase
env.npm_config_http_proxy = 'http://http-proxy';
// eslint-disable-next-line camelcase
env.npm_config_proxy = 'http://unexpected-proxy';
env.HTTP_PROXY = 'http://unexpected-proxy';
testProxyUrl(env, 'http://http-proxy', 'http://example');
});
describe('npm_config_https_proxy should work', function() {
var env = {};
// eslint-disable-next-line camelcase
env.npm_config_http_proxy = 'http://unexpected.proxy';
testProxyUrl(env, '', 'https://example');
// eslint-disable-next-line camelcase
env.npm_config_https_proxy = 'http://https-proxy';
testProxyUrl(env, 'http://https-proxy', 'https://example');
// eslint-disable-next-line camelcase
env.npm_config_https_proxy = 'http://priority';
testProxyUrl(env, 'http://priority', 'https://example');
});
// eslint-disable-next-line max-len
describe('npm_config_https_proxy should take precedence over HTTPS_PROXY and npm_config_proxy', function() {
var env = {};
// eslint-disable-next-line camelcase
env.npm_config_https_proxy = 'http://https-proxy';
// eslint-disable-next-line camelcase
env.npm_config_proxy = 'http://unexpected-proxy';
env.HTTPS_PROXY = 'http://unexpected-proxy';
testProxyUrl(env, 'http://https-proxy', 'https://example');
});
describe('npm_config_proxy should work', function() {
var env = {};
// eslint-disable-next-line camelcase
env.npm_config_proxy = 'http://http-proxy';
testProxyUrl(env, 'http://http-proxy', 'http://example');
testProxyUrl(env, 'http://http-proxy', 'https://example');
// eslint-disable-next-line camelcase
env.npm_config_proxy = 'http://priority';
testProxyUrl(env, 'http://priority', 'http://example');
testProxyUrl(env, 'http://priority', 'https://example');
});
// eslint-disable-next-line max-len
describe('HTTP_PROXY and HTTPS_PROXY should take precedence over npm_config_proxy', function() {
var env = {};
env.HTTP_PROXY = 'http://http-proxy';
env.HTTPS_PROXY = 'http://https-proxy';
// eslint-disable-next-line camelcase
env.npm_config_proxy = 'http://unexpected-proxy';
testProxyUrl(env, 'http://http-proxy', 'http://example');
testProxyUrl(env, 'http://https-proxy', 'https://example');
});
describe('npm_config_no_proxy should work', function() {
var env = {};
env.HTTP_PROXY = 'http://proxy';
// eslint-disable-next-line camelcase
env.npm_config_no_proxy = 'example';
testProxyUrl(env, '', 'http://example');
testProxyUrl(env, 'http://proxy', 'http://otherwebsite');
});
// eslint-disable-next-line max-len
describe('npm_config_no_proxy should take precedence over NO_PROXY', function() {
var env = {};
env.HTTP_PROXY = 'http://proxy';
env.NO_PROXY = 'otherwebsite';
// eslint-disable-next-line camelcase
env.npm_config_no_proxy = 'example';
testProxyUrl(env, '', 'http://example');
testProxyUrl(env, 'http://proxy', 'http://otherwebsite');
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc