Skip to content

Commit

Permalink
Add proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
thtliife committed May 22, 2019
1 parent a5de735 commit a7e2c4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/normalize-arguments.ts
@@ -1,5 +1,6 @@
import urlLib, {URL, URLSearchParams} from 'url'; // TODO: Use the `URL` global when targeting Node.js 10
import CacheableLookup from 'cacheable-lookup';
import ProxyAgent from 'https-proxy-agent';
import is from '@sindresorhus/is';
import lowercaseKeys from 'lowercase-keys';
import urlToOptions from './utils/url-to-options';
Expand Down Expand Up @@ -183,6 +184,11 @@ export const normalizeArguments = (url, options, defaults?: any) => {
options.path = `${options.path.split('?')[0]}?${searchParams}`;
}

const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || undefined;
if (is.nonEmptyString(proxy)) {
options.agent = new ProxyAgent(proxy);
}

if (options.hostname === 'unix') {
const matches = /(.+?):(.+)/.exec(options.path);

Expand Down

0 comments on commit a7e2c4f

Please sign in to comment.