Skip to content

Commit c3d0540

Browse files
committed
fixing bug where CIDR is not properly initialized when only IP is passed
1 parent 87be911 commit c3d0540

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Given a list of IP address ranges, minify that list to the smallest possible size by performing the following
77
optimizations:
88

9-
- removing duplicate IP ranges from the list
9+
- removing invalid IP addresses/ranges from the list
10+
- removing duplicates
1011
- removing IP ranges already covered by larger ranges in the list
1112
- merging adjacent IP ranges into larger, contiguous blocks
1213

src/CIDR.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ protected function parseOrFail(string $cidrNotation): void
3434
$onlyIp = filter_var(trim($cidrNotation), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
3535

3636
if ($onlyIp) {
37-
$this->prefix = $onlyIp;
38-
$this->length = 32;
37+
$this->parseOrFail($onlyIp . '/32');
3938
return;
4039
}
4140

0 commit comments

Comments
 (0)