MCPcopy
hub / github.com/axios/axios / isIPv6Unspecified

Function isIPv6Unspecified

lib/helpers/shouldBypassProxy.js:16–39  ·  view source on GitHub ↗
(host)

Source from the content-addressed store, hash-verified

14// matching. 0.0.0.0 is covered by LOOPBACK_HOSTNAMES; this handles compressed
15// and full IPv6 all-zero forms so both families bypass symmetrically.
16const isIPv6Unspecified = (host) => {
17 if (host === '::') return true;
18
19 const compressionIndex = host.indexOf('::');
20
21 if (compressionIndex !== -1) {
22 if (compressionIndex !== host.lastIndexOf('::')) return false;
23
24 const left = host.slice(0, compressionIndex);
25 const right = host.slice(compressionIndex + 2);
26 const leftGroups = left ? left.split(':') : [];
27 const rightGroups = right ? right.split(':') : [];
28 const explicitGroups = leftGroups.length + rightGroups.length;
29
30 return (
31 explicitGroups < 8 &&
32 leftGroups.every(isIPv6ZeroGroup) &&
33 rightGroups.every(isIPv6ZeroGroup)
34 );
35 }
36
37 const groups = host.split(':');
38 return groups.length === 8 && groups.every(isIPv6ZeroGroup);
39};
40
41const isIPv6Loopback = (host) => {
42 // Collapse all-zero groups: any form of ::1 / 0:0:...:0:1

Callers 1

isLoopbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected