




















@@ -1,7 +1,7 @@
11import { describe, expect, it } from "vitest";
22import {
3-hasEnvHttpProxyAgentConfigured,
43hasEnvHttpProxyConfigured,
4+hasEnvHttpProxyAgentConfigured,
55hasProxyEnvConfigured,
66matchesNoProxy,
77resolveEnvHttpProxyAgentOptions,
@@ -293,6 +293,36 @@ describe("matchesNoProxy", () => {
293293env: { NO_PROXY: "[::1]:8080" } as NodeJS.ProcessEnv,
294294expected: true,
295295},
296+{
297+name: "matches IPv4 CIDR entries",
298+url: "http://100.64.0.3:8990/v1/messages",
299+env: { NO_PROXY: "100.64.0.0/10" } as NodeJS.ProcessEnv,
300+expected: true,
301+},
302+{
303+name: "matches IPv4 wildcard octet entries",
304+url: "http://100.64.0.3:8990/v1/messages",
305+env: { NO_PROXY: "100.64.*" } as NodeJS.ProcessEnv,
306+expected: true,
307+},
308+{
309+name: "matches IPv4 wildcard octets one octet at a time",
310+url: "http://8.1.8.8:8990/v1/messages",
311+env: { NO_PROXY: "8.*.8.8" } as NodeJS.ProcessEnv,
312+expected: true,
313+},
314+{
315+name: "does not let non-final IPv4 wildcards ignore remaining octets",
316+url: "http://8.1.2.3:8990/v1/messages",
317+env: { NO_PROXY: "8.*.8.8" } as NodeJS.ProcessEnv,
318+expected: false,
319+},
320+{
321+name: "does not match IPv4 CIDR outside range",
322+url: "http://100.128.0.3:8990/v1/messages",
323+env: { NO_PROXY: "100.64.0.0/10" } as NodeJS.ProcessEnv,
324+expected: false,
325+},
296326{
297327name: "returns false for malformed target URL",
298328url: "not-a-url",
@@ -339,6 +369,24 @@ describe("shouldUseEnvHttpProxyForUrl", () => {
339369} as NodeJS.ProcessEnv,
340370expected: false,
341371},
372+{
373+name: "keeps strict mode for NO_PROXY CIDR matches",
374+url: "http://100.64.0.3:8990/v1/messages",
375+env: {
376+HTTP_PROXY: "http://proxy.test:8080",
377+NO_PROXY: "100.64.0.0/10",
378+} as NodeJS.ProcessEnv,
379+expected: false,
380+},
381+{
382+name: "keeps strict mode for NO_PROXY IP wildcard matches",
383+url: "http://100.64.0.3:8990/v1/messages",
384+env: {
385+HTTP_PROXY: "http://proxy.test:8080",
386+NO_PROXY: "100.64.*",
387+} as NodeJS.ProcessEnv,
388+expected: false,
389+},
342390{
343391name: "keeps strict mode for non-http URLs",
344392url: "file:///tmp/input.txt",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。