From b3b76366bfffacb8c4701f10e44d8d08995ce5bb Mon Sep 17 00:00:00 2001 From: skidoodle Date: Sat, 7 Mar 2026 00:53:48 +0100 Subject: [PATCH] asn failsafe --- services/geo.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/geo.ts b/services/geo.ts index 6616cf7..699ae45 100644 --- a/services/geo.ts +++ b/services/geo.ts @@ -65,6 +65,8 @@ export const GeoService = { }, transform(ip: string, apiData: any): GeoData { + const asnMatch = apiData.org?.match(/^AS\d+/i); + return { ip, hostname: apiData.hostname || null, @@ -73,10 +75,10 @@ export const GeoService = { city: apiData.city || null, region: apiData.region || null, org: apiData.org || null, - asn: apiData.org?.split(' ')[0] || null, + asn: asnMatch ? asnMatch[0].toUpperCase() : null, timezone: apiData.timezone || null, isLocal: false, isBogon: apiData.bogon || false }; } -}; +}