@@ -62,30 +62,6 @@ Deno.test("matchSubnets()", () => {
62
62
] ;
63
63
64
64
const list = [
65
- // IPv4 exact and CIDR matches
66
- { addr : "192.168.1.10" , subnets : [ "192.168.1.10" ] , expected : true } ,
67
- { addr : "192.168.1.10" , subnets : [ "192.168.1.11" ] , expected : false } ,
68
- { addr : "192.168.1.10" , subnets : [ "192.168.1.0/24" ] , expected : true } ,
69
- { addr : "192.168.1.255" , subnets : [ "192.168.1.0/24" ] , expected : true } ,
70
- { addr : "192.168.2.10" , subnets : [ "192.168.1.0/24" ] , expected : false } ,
71
- { addr : "192.168.100.10" , subnets : [ "192.168.0.0/16" ] , expected : true } ,
72
- { addr : "192.169.1.10" , subnets : [ "192.168.0.0/16" ] , expected : false } ,
73
- { addr : "192.100.100.100" , subnets : [ "192.0.0.0/8" ] , expected : true } ,
74
- { addr : "193.1.1.1" , subnets : [ "192.0.0.0/8" ] , expected : false } ,
75
- { addr : "192.168.1.10" , subnets : [ "192.168.1.10/32" ] , expected : true } ,
76
- { addr : "192.168.1.11" , subnets : [ "192.168.1.10/32" ] , expected : false } ,
77
-
78
- // IPv6 exact and subnet matches
79
- { addr : "2001:db8::1" , subnets : [ "2001:db8::1" ] , expected : true } ,
80
- { addr : "2001:db8::1" , subnets : [ "2001:db8::2" ] , expected : false } ,
81
- { addr : "::1" , subnets : [ "::1" ] , expected : true } ,
82
- { addr : "2001:db8::1" , subnets : [ "2001:db8::/64" ] , expected : true } ,
83
- { addr : "2001:db9::1" , subnets : [ "2001:db8::/64" ] , expected : false } ,
84
- { addr : "2001:db8:1234::1" , subnets : [ "2001:db8::/32" ] , expected : true } ,
85
- { addr : "2001:db9::1" , subnets : [ "2001:db8::/32" ] , expected : false } ,
86
- { addr : "::" , subnets : [ "::/0" ] , expected : true } ,
87
- { addr : "2001:db8::1" , subnets : [ "::/0" ] , expected : true } ,
88
-
89
65
// Multiple and mixed subnets
90
66
{ addr : "192.168.1.50" , subnets : mixed , expected : true } ,
91
67
{ addr : "10.5.5.5" , subnets : mixed , expected : true } ,
@@ -116,9 +92,9 @@ Deno.test("matchIPv4Subnet()", () => {
116
92
{ addr : "192.168.1.10" , subnet : "192.168.1.0/24" , expected : true } ,
117
93
{ addr : "192.168.1.11" , subnet : "/32" , expected : false } ,
118
94
{ addr : "192.168.1" , subnet : "192.168.1/32" , expected : false } ,
119
- { addr : "192.168.1.1" , subnet : "192.168.1.0/" , expected : false } , // Missing prefix length
120
- { addr : "192.168.1.1" , subnet : "192.168.1.0/33" , expected : false } , // Invalid prefix length
121
- { addr : "192.168.1.1" , subnet : "192.168.1.0/0" , expected : true } , // /0 prefix (all IPs)
95
+ { addr : "192.168.1.1" , subnet : "192.168.1.0/" , expected : false } ,
96
+ { addr : "192.168.1.1" , subnet : "192.168.1.0/33" , expected : false } ,
97
+ { addr : "192.168.1.1" , subnet : "192.168.1.0/0" , expected : true } ,
122
98
] ;
123
99
124
100
for ( const { addr, subnet, expected } of list ) {
@@ -158,6 +134,7 @@ Deno.test("matchIPv6Subnet()", () => {
158
134
// Additional edge cases
159
135
{ addr : "2001:db8::1" , subnet : "2001:db8::1/-1" , expected : false } ,
160
136
{ addr : "2001:db8::1" , subnet : "2001:db8::1/abc" , expected : false } ,
137
+
161
138
//IPv6 with embedded IPv4
162
139
{
163
140
addr : "2001:db8::ffff:192.168.1.1.1" ,
0 commit comments