Skip to content

Commit 59dee1c

Browse files
committed
When detecting the existence of a proxy environment variable, check for HTTP versus HTTPS and uppercase vs lowercase
1 parent c3e130b commit 59dee1c

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/core/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ var folder = process.platform === 'win32'
2222
? 'bower'
2323
: '.bower';
2424

25+
var proxy = process.env.HTTPS_PROXY
26+
|| process.env.https_proxy
27+
|| process.env.HTTP_PROXY
28+
|| process.env.http_proxy;
29+
2530
// Bower Config
2631
var config;
2732
try {
@@ -31,7 +36,8 @@ try {
3136
completion : path.join(roaming, folder, 'completion'),
3237
json : 'component.json',
3338
endpoint : 'https://bower.herokuapp.com',
34-
directory : 'components'
39+
directory : 'components',
40+
proxy : proxy
3541
});
3642
} catch (e) {
3743
throw new Error('Unable to parse global .bowerrc file: ' + e.message);

lib/core/package.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ Package.prototype.download = function () {
402402

403403
var src;
404404

405-
if (process.env.HTTP_PROXY) {
406-
src = url.parse(process.env.HTTP_PROXY);
405+
if (config.proxy) {
406+
src = url.parse(config.proxy);
407407
src.path = this.assetUrl;
408408
} else {
409409
src = url.parse(this.assetUrl);
@@ -601,7 +601,7 @@ Package.prototype.cache = function () {
601601
}
602602
template('action', { name: 'caching', shizzle: this.gitUrl }).on('data', this.emit.bind(this, 'data'));
603603
var url = this.gitUrl;
604-
if (process.env.HTTP_PROXY) {
604+
if (config.proxy) {
605605
url = url.replace(/^git:/, 'https:');
606606
}
607607

lib/core/source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ var config = require('./config');
1111

1212
var endpoint = config.endpoint + '/packages';
1313

14-
if (process.env.HTTP_PROXY) {
15-
request = request.defaults({ proxy: process.env.HTTP_PROXY, timeout: 5000 });
14+
if (config.proxy) {
15+
request = request.defaults({ proxy: config.proxy, timeout: 5000 });
1616
}
1717

1818

0 commit comments

Comments
 (0)