Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Sanitize IP to remove port for geolocation lookup
Alex Escalante26ddfd5a8068
diff --git a/src/lib/detect.ts b/src/lib/detect.tsindex a023d27d2..ae750469b 100644--- a/src/lib/detect.ts+++ b/src/lib/detect.ts@@ -127,7 +127,9 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadIglobal[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));}- const result = global[MAXMIND].get(ip);+ // When the client IP is extracted from headers, sometimes the value includes a port+ const cleanIp = ip?.split(':')[0];+ const result = global[MAXMIND].get(cleanIp);if (result) {const country = result.country?.iso_code ?? result?.registered_country?.iso_code;