teeny-request
Advanced tools
Comparing version 7.1.3 to 7.2.0
@@ -26,2 +26,28 @@ "use strict"; | ||
/** | ||
* Determines if a proxy should be considered based on the environment. | ||
* | ||
* @param uri The request uri | ||
* @returns {boolean} | ||
*/ | ||
function shouldUseProxyForURI(uri) { | ||
const noProxyEnv = process.env.NO_PROXY || process.env.no_proxy; | ||
if (!noProxyEnv) { | ||
return true; | ||
} | ||
const givenURI = new URL(uri); | ||
for (const noProxyRaw of noProxyEnv.split(',')) { | ||
const noProxy = noProxyRaw.trim(); | ||
if (noProxy === givenURI.origin || noProxy === givenURI.hostname) { | ||
return false; | ||
} | ||
else if (noProxy.startsWith('*.') || noProxy.startsWith('.')) { | ||
const noProxyWildcard = noProxy.replace(/^\*\./, '.'); | ||
if (givenURI.hostname.endsWith(noProxyWildcard)) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
/** | ||
* Returns a custom request Agent if one is found, otherwise returns undefined | ||
@@ -42,3 +68,5 @@ * which will result in the global http(s) Agent being used. | ||
const poolOptions = Object.assign({}, reqOpts.pool); | ||
if (proxy) { | ||
const manuallyProvidedProxy = !!reqOpts.proxy; | ||
const shouldUseProxy = manuallyProvidedProxy || shouldUseProxyForURI(uri); | ||
if (proxy && shouldUseProxy) { | ||
// tslint:disable-next-line variable-name | ||
@@ -45,0 +73,0 @@ const Agent = isHttp |
# Changelog | ||
## [7.2.0](https://github.com/googleapis/teeny-request/compare/v7.1.3...v7.2.0) (2022-03-31) | ||
### Features | ||
* Add support for `NO_PROXY` ([#272](https://github.com/googleapis/teeny-request/issues/272)) ([b02b6e5](https://github.com/googleapis/teeny-request/commit/b02b6e515575814bbef7360586d07030b445705d)) | ||
### [7.1.3](https://www.github.com/googleapis/teeny-request/compare/v7.1.2...v7.1.3) (2021-09-24) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "teeny-request", | ||
"version": "7.1.3", | ||
"version": "7.2.0", | ||
"description": "Like request, but smaller.", | ||
@@ -59,3 +59,3 @@ "main": "./build/src/index.js", | ||
"nock": "^13.0.0", | ||
"sinon": "^10.0.0", | ||
"sinon": "^13.0.0", | ||
"typescript": "^3.8.3" | ||
@@ -62,0 +62,0 @@ }, |
@@ -74,3 +74,3 @@ [![Build Status](https://travis-ci.org/googleapis/teeny-request.svg?branch=master)](https://travis-ci.org/googleapis/teeny-request) | ||
## Proxy environment variables | ||
If environment variables `HTTP_PROXY` or `HTTPS_PROXY` are set, they are respected. `NO_PROXY` is currently not implemented. | ||
If environment variables `HTTP_PROXY`, `HTTPS_PROXY`, or `NO_PROXY` are set, they are respected. | ||
@@ -77,0 +77,0 @@ ## Building with Webpack 4+ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64376
732
7