MCPcopy Index your code
hub / github.com/simstudioai/sim / isPrivateIPv4

Function isPrivateIPv4

apps/sim/app/api/tools/sap_concur/shared.ts:111–124  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

109])
110
111function isPrivateIPv4(host: string): boolean {
112 const match = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
113 if (!match) return false
114 const octets = match.slice(1, 5).map(Number) as [number, number, number, number]
115 if (octets.some((o) => o < 0 || o > 255)) return false
116 const [a, b] = octets
117 if (a === 10) return true
118 if (a === 172 && b >= 16 && b <= 31) return true
119 if (a === 192 && b === 168) return true
120 if (a === 127) return true
121 if (a === 169 && b === 254) return true
122 if (a === 0) return true
123 return false
124}
125
126function isPrivateOrLoopbackIPv6(host: string): boolean {
127 const stripped = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host

Callers 1

assertSafeExternalUrlFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected