mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 10:35:35 +01:00
Updated subdivision check.
This commit is contained in:
parent
33ffa0b3d1
commit
61df80112a
1 changed files with 10 additions and 2 deletions
|
|
@ -57,6 +57,14 @@ export function getDevice(screen, os) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRegionCode(country, region) {
|
||||||
|
if (!country || !region) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return region.includes('-') ? region : `${country}-${region}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getLocation(ip, req) {
|
export async function getLocation(ip, req) {
|
||||||
// Ignore local ips
|
// Ignore local ips
|
||||||
if (await isLocalhost(ip)) {
|
if (await isLocalhost(ip)) {
|
||||||
|
|
@ -71,7 +79,7 @@ export async function getLocation(ip, req) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
country,
|
country,
|
||||||
subdivision1: subdivision1?.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
|
subdivision1: getRegionCode(country, subdivision1),
|
||||||
city,
|
city,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +92,7 @@ export async function getLocation(ip, req) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
country,
|
country,
|
||||||
subdivision1: subdivision1?.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
|
subdivision1: getRegionCode(country, subdivision1),
|
||||||
city,
|
city,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue