fix: handle multi-IP and add tests for clickable IP link
Follow-up to #78: - Use primaryIp() so href targets the first IP when data.ip is comma-separated (e.g. "192.168.1.1, 2001:db8::1") - Add primaryIp() helper to maskIp.ts - Add 4 tests covering single IP link, absent IP, multi-IP href, multi-IP display text
This commit is contained in:
@@ -8,3 +8,8 @@ export function maskIp(ip: string): string {
|
||||
if (parts.length === 4) return `${parts[0]}.${parts[1]}.XX.XX`
|
||||
return ip
|
||||
}
|
||||
|
||||
export function primaryIp(ip: string): string {
|
||||
if (!ip?.trim()) return ''
|
||||
return ip.split(',')[0].trim()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user