@@ -453,8 +453,11 @@ defmodule PlausibleWeb.Api.ExternalController do
453453 ip = PlausibleWeb.RemoteIp . get ( conn )
454454
455455 case :locus . lookup ( :geolocation , ip ) do
456- { :ok , result } -> get_location_details ( result )
457- _ -> get_location_details ( % { } )
456+ { :ok , result } ->
457+ get_location_details ( result )
458+
459+ _ ->
460+ get_location_details ( nil )
458461 end
459462 end
460463
@@ -467,7 +470,7 @@ defmodule PlausibleWeb.Api.ExternalController do
467470 }
468471 end
469472
470- defp get_country_code ( % { } ) , do: ""
473+ defp get_country_code ( nil ) , do: ""
471474
472475 defp get_country_code ( geo_data ) do
473476 geo_data
@@ -476,7 +479,7 @@ defmodule PlausibleWeb.Api.ExternalController do
476479 |> ignore_unknown_country ( )
477480 end
478481
479- defp get_city_geoname_id ( % { } ) , do: ""
482+ defp get_city_geoname_id ( nil ) , do: ""
480483
481484 defp get_city_geoname_id ( geo_data ) do
482485 city =
@@ -487,7 +490,7 @@ defmodule PlausibleWeb.Api.ExternalController do
487490 Map . get ( @ city_overrides , city , city )
488491 end
489492
490- defp get_subdivision_code ( % { } , _ ) , do: ""
493+ defp get_subdivision_code ( nil , _ ) , do: ""
491494
492495 defp get_subdivision_code ( geo_data , n ) do
493496 subdivisions = Map . get ( geo_data , "subdivision" , [ ] )
0 commit comments