@redocly/cli
Version:
[@Redocly](https://redocly.com) CLI is your all-in-one API documentation utility. It builds, manages, improves, and quality-checks your API descriptions, all of which comes in handy for various phases of the API Lifecycle. Create your own rulesets to make
41 lines • 1.2 kB
JavaScript
import { HttpsProxyAgent } from 'https-proxy-agent';
export function getProxyUrl() {
return (process.env.HTTPS_PROXY ||
process.env.HTTP_PROXY ||
process.env.http_proxy ||
process.env.https_proxy);
}
export function getProxyAgent() {
const proxy = getProxyUrl();
return proxy ? new HttpsProxyAgent(proxy) : undefined;
}
export function shouldBypassProxy(url) {
const noProxy = process.env.NO_PROXY || process.env.no_proxy;
if (!noProxy)
return false;
const entries = noProxy
.split(',')
.map((s) => s.trim().toLowerCase())
.filter(Boolean);
if (entries.length === 0)
return false;
let hostname;
try {
hostname = new URL(url).hostname.toLowerCase();
}
catch {
return false;
}
return entries.some((entry) => {
if (entry === '*')
return true;
if (hostname === entry)
return true;
if (entry.startsWith('.') && hostname.endsWith(entry))
return true;
if (!entry.startsWith('.') && hostname.endsWith('.' + entry))
return true;
return false;
});
}
//# sourceMappingURL=proxy-agent.js.map