(env: Env = process.env)
| 130 | * through the proxy. |
| 131 | */ |
| 132 | export function resolveNoProxy(env: Env = process.env): string { |
| 133 | // Prefer the first non-blank casing; an empty `no_proxy=''` must not mask a |
| 134 | // populated `NO_PROXY` (`??` would, since `''` is not nullish). |
| 135 | const raw = [env['no_proxy'], env['NO_PROXY']].find((value) => (value?.trim() ?? '').length > 0) ?? ''; |
| 136 | const hosts = raw |
| 137 | .split(',') |
| 138 | .map((host) => host.trim()) |
| 139 | .filter((host) => host.length > 0); |
| 140 | if (hosts.includes('*')) return '*'; |
| 141 | for (const loopback of LOOPBACK_NO_PROXY) { |
| 142 | if (!hosts.includes(loopback)) hosts.push(loopback); |
| 143 | } |
| 144 | return hosts.join(','); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Build a predicate that returns true when a host (and optional port) should |
no test coverage detected