mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 18:00:17 +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);
|
const result = lookup.get(ip);
|
||||||
|
|
||||||
if (result) {
|
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 {
|
return {
|
||||||
country: result.country?.iso_code ?? result?.registered_country?.iso_code,
|
country,
|
||||||
subdivision1: result.subdivisions?.[0]?.iso_code,
|
subdivision1: getRegionCode(country, subdivision1),
|
||||||
subdivision2: result.subdivisions?.[1]?.names?.en,
|
subdivision2,
|
||||||
city: result.city?.names?.en,
|
city,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user