MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / makeNoProxyMatcher

Function makeNoProxyMatcher

packages/agent-core/src/utils/proxy.ts:154–170  ·  view source on GitHub ↗
(noProxy: string)

Source from the content-addressed store, hash-verified

152 * the SOCKS path, where bypass is not handled by undici for us.
153 */
154export 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.

Callers 2

proxy.test.tsFile · 0.90
defaultMakeSocksAgentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected