mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge pull request #3498 from AlexEscalante/sanitize-ip
Sanitize IP to remove port for geolocation lookup
This commit is contained in:
commit
74f0bdab89
1 changed files with 3 additions and 1 deletions
|
|
@ -127,7 +127,9 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
|||
global[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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue