cidrv6Overlaps(): boolean
Checks if two IPv6 CIDR blocks overlap (share at least one address).
Two CIDRs overlap when one contains at least one address of the other.
This is equivalent to checking containment using the shorter prefix.
The check is symmetric: cidrv6Overlaps(a, b) === cidrv6Overlaps(b, a).
Overlapping CIDRs
Overlapping CIDRs
import { assert, assertEquals } from "@std/assert"; import { cidrv6Overlaps, parseCidrv6 } from "@hertzg/ip/cidrv6"; assert(cidrv6Overlaps(parseCidrv6("2001:db8::/32"), parseCidrv6("2001:db8:1::/48"))); assert(cidrv6Overlaps(parseCidrv6("2001:db8:1::/48"), parseCidrv6("2001:db8::/32"))); assert(cidrv6Overlaps(parseCidrv6("fd00::/120"), parseCidrv6("fd00::/120"))); assertEquals(cidrv6Overlaps(parseCidrv6("2001:db8::/32"), parseCidrv6("2001:db9::/32")), false);