mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-25 20:02:46 +01:00
Merge pull request #2388 from Maxime-J/subdivision1
Ensure country in region code
This commit is contained in:
commit
cde85d7db7
@ -107,11 +107,16 @@ export async function getLocation(ip, req) {
|
||||
const result = lookup.get(ip);
|
||||
|
||||
if (result) {
|
||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||
const subdivision1 = result.subdivisions?.[0]?.iso_code;
|
||||
const subdivision2 = result.subdivisions?.[1]?.names?.en;
|
||||
const city = result.city?.names?.en;
|
||||
|
||||
return {
|
||||
country: result.country?.iso_code ?? result?.registered_country?.iso_code,
|
||||
subdivision1: result.subdivisions?.[0]?.iso_code,
|
||||
subdivision2: result.subdivisions?.[1]?.names?.en,
|
||||
city: result.city?.names?.en,
|
||||
country,
|
||||
subdivision1: getRegionCode(country, subdivision1),
|
||||
subdivision2,
|
||||
city,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user