Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Provider/GeoIP2/GeoIP2.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public function __construct(GeoIP2Adapter $adapter)
public function geocodeQuery(GeocodeQuery $query): Collection
{
$address = $query->getText();
$address = explode(',', $address)[0];
$locale = $query->getLocale() ?: 'en'; // Default to English
if (!filter_var($address, FILTER_VALIDATE_IP)) {
throw new UnsupportedOperation('The GeoIP2 provider does not support street addresses, only IP addresses.');
throw new UnsupportedOperation(sprintf('"%s" must be called with an IP addresses. Got "%s" instead.', __METHOD__, $address));
}

if ('127.0.0.1' === $address) {
Expand Down Expand Up @@ -110,6 +111,7 @@ public function getName(): string
*/
private function executeQuery(string $address): string
{
$address = explode(',', $address)[0];
$uri = sprintf('file://geoip?%s', $address);

try {
Expand Down