blob: 1e14c63936a7e1f3a166853449da80d2f561b6fa [file] [log] [blame]
Tim van der Lippe652ccb72021-05-27 17:07:12 +01001var url = require('url');
2
3var override = require('../utils/override');
4
5function inlineRequestFrom(option) {
6 return override(
7 /* jshint camelcase: false */
8 proxyOptionsFrom(process.env.HTTP_PROXY || process.env.http_proxy),
9 option || {}
10 );
11}
12
13function proxyOptionsFrom(httpProxy) {
14 return httpProxy ?
15 {
16 hostname: url.parse(httpProxy).hostname,
17 port: parseInt(url.parse(httpProxy).port)
18 } :
19 {};
20}
21
22module.exports = inlineRequestFrom;