* Honors the `no_proxy` env variable with the highest priority to allow for hosts exclusion. * * @param transportUrl The URL the transport intends to send events to. * @param proxy The client configured proxy. * @returns A proxy the transport should use.
(transportUrlSegments: URL, proxy: string | undefined)
| 88 | * @returns A proxy the transport should use. |
| 89 | */ |
| 90 | function applyNoProxyOption(transportUrlSegments: URL, proxy: string | undefined): string | undefined { |
| 91 | const { no_proxy } = process.env; |
| 92 | |
| 93 | const urlIsExemptFromProxy = no_proxy |
| 94 | ?.split(',') |
| 95 | .some( |
| 96 | exemption => transportUrlSegments.host.endsWith(exemption) || transportUrlSegments.hostname.endsWith(exemption), |
| 97 | ); |
| 98 | |
| 99 | if (urlIsExemptFromProxy) { |
| 100 | return undefined; |
| 101 | } else { |
| 102 | return proxy; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Creates a RequestExecutor to be used with `createTransport`. |