diff --git a/src/Countries.php b/src/Countries.php index fbfd5e4..f0f6a28 100644 --- a/src/Countries.php +++ b/src/Countries.php @@ -368,6 +368,10 @@ public function validateCountryCode(string $countryCode) : bool */ public function validateIpAddress(string $ipAddress) : bool { + if (empty($ipAddress)) { + return false; + } + return (bool) filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE); } @@ -382,7 +386,7 @@ public function validateIpAddress(string $ipAddress) : bool */ public function ip(string $ipAddress) : string { - if (empty($ipAddress) || !$this->validateIpAddress($ipAddress)) { + if (!$this->validateIpAddress($ipAddress)) { return ''; }