mirror of
https://github.com/skidoodle/hostinfo
synced 2026-04-28 01:27:36 +02:00
asn failsafe
This commit is contained in:
+4
-2
@@ -65,6 +65,8 @@ export const GeoService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
transform(ip: string, apiData: any): GeoData {
|
transform(ip: string, apiData: any): GeoData {
|
||||||
|
const asnMatch = apiData.org?.match(/^AS\d+/i);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ip,
|
ip,
|
||||||
hostname: apiData.hostname || null,
|
hostname: apiData.hostname || null,
|
||||||
@@ -73,10 +75,10 @@ export const GeoService = {
|
|||||||
city: apiData.city || null,
|
city: apiData.city || null,
|
||||||
region: apiData.region || null,
|
region: apiData.region || null,
|
||||||
org: apiData.org || null,
|
org: apiData.org || null,
|
||||||
asn: apiData.org?.split(' ')[0] || null,
|
asn: asnMatch ? asnMatch[0].toUpperCase() : null,
|
||||||
timezone: apiData.timezone || null,
|
timezone: apiData.timezone || null,
|
||||||
isLocal: false,
|
isLocal: false,
|
||||||
isBogon: apiData.bogon || false
|
isBogon: apiData.bogon || false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user