chore: pr polish (#596)

This commit is contained in:
Anoop M D
2023-10-18 10:25:01 +05:30
parent d767a144f2
commit d809a58deb
12 changed files with 103 additions and 162 deletions

View File

@@ -129,7 +129,7 @@ const runSingleRequest = async function (
// set proxy if enabled
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
const shouldProxy = shouldUseProxy(request.url, get(brunoConfig, 'proxy.noProxy', ''));
const shouldProxy = shouldUseProxy(request.url, get(brunoConfig, 'proxy.bypassProxy', ''));
if (proxyEnabled && shouldProxy) {
const proxyProtocol = interpolateString(get(brunoConfig, 'proxy.protocol'), interpolationOptions);
const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions);

View File

@@ -11,13 +11,14 @@ const DEFAULT_PORTS = {
/**
* check for proxy bypass, Copied form 'proxy-from-env'
*/
const shouldUseProxy = (url, proxyByPass) => {
if (proxyByPass === '*') {
const shouldUseProxy = (url, proxyBypass) => {
if (proxyBypass === '*') {
return false; // Never proxy if wildcard is set.
}
if (!proxyByPass) {
return true; // use proxy if enabled
// use proxy if no proxyBypass is set
if (!proxyBypass || typeof proxyBypass !== 'string' || isEmpty(proxyBypass.trim())) {
return true;
}
const parsedUrl = typeof url === 'string' ? parseUrl(url) : url || {};
@@ -34,7 +35,7 @@ const shouldUseProxy = (url, proxyByPass) => {
hostname = hostname.replace(/:\d*$/, '');
port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
return proxyByPass.split(/[,;\s]/).every(function (dontProxyFor) {
return proxyBypass.split(/[,;\s]/).every(function (dontProxyFor) {
if (!dontProxyFor) {
return true; // Skip zero-length hosts.
}