(noProxy: string)
| 152 | * the SOCKS path, where bypass is not handled by undici for us. |
| 153 | */ |
| 154 | export function makeNoProxyMatcher(noProxy: string): (host: string, port?: number | string) => boolean { |
| 155 | const entries = noProxy |
| 156 | .split(',') |
| 157 | .map((entry) => entry.trim().toLowerCase()) |
| 158 | .filter((entry) => entry.length > 0); |
| 159 | if (entries.includes('*')) return () => true; |
| 160 | const parsed = entries.map(parseNoProxyEntry); |
| 161 | return (host: string, port?: number | string) => { |
| 162 | const target = host.toLowerCase().replaceAll(/^\[|\]$/g, ''); |
| 163 | const targetPort = port === undefined ? undefined : String(port); |
| 164 | return parsed.some( |
| 165 | ({ host: entry, port: entryPort }) => |
| 166 | (entryPort === undefined || entryPort === targetPort) && |
| 167 | (target === entry || target.endsWith(`.${entry}`)), |
| 168 | ); |
| 169 | }; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Split a `NO_PROXY` entry into host (leading `.` stripped) and optional port. |
no outgoing calls
no test coverage detected