From 827b2a3b8a7b6059c84924515ebdde15312e7cb1 Mon Sep 17 00:00:00 2001 From: efiten Date: Sat, 28 Mar 2026 17:20:25 +0100 Subject: [PATCH] fix: HB column always shows 1-4, remove null fallback Every packet has a path byte so hash bytes is always 1-4. Co-Authored-By: Claude Sonnet 4.6 --- public/packets.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/public/packets.js b/public/packets.js index ac4bf90a..68a2daeb 100644 --- a/public/packets.js +++ b/public/packets.js @@ -1021,8 +1021,7 @@ const groupTypeName = payloadTypeName(p.payload_type); const groupTypeClass = payloadTypeColor(p.payload_type); const groupSize = p.raw_hex ? Math.floor(p.raw_hex.length / 2) : 0; - const groupRawPathByte = p.raw_hex ? parseInt(p.raw_hex.slice(2, 4), 16) : NaN; - const groupHashBytes = isNaN(groupRawPathByte) ? null : ((groupRawPathByte >> 6) + 1); + const groupHashBytes = ((parseInt(p.raw_hex?.slice(2, 4), 16) || 0) >> 6) + 1; const isSingle = p.count <= 1; html += ` ${isSingle ? '' : (isExpanded ? '▼' : '▶')} @@ -1030,7 +1029,7 @@ ${timeAgo(p.latest)} ${truncate(p.hash || '—', 8)} ${groupSize ? groupSize + 'B' : '—'} - ${groupHashBytes !== null ? groupHashBytes : '—'} + ${groupHashBytes} ${p.payload_type != null ? `${groupTypeName}` : '—'} ${isSingle ? truncate(obsName(headerObserverId), 16) : truncate(obsName(headerObserverId), 10) + (p.observer_count > 1 ? ' +' + (p.observer_count - 1) : '')} ${groupPathStr} @@ -1049,8 +1048,7 @@ const typeName = payloadTypeName(c.payload_type); const typeClass = payloadTypeColor(c.payload_type); const size = c.raw_hex ? Math.floor(c.raw_hex.length / 2) : 0; - const childRawPathByte = c.raw_hex ? parseInt(c.raw_hex.slice(2, 4), 16) : NaN; - const childHashBytes = isNaN(childRawPathByte) ? null : ((childRawPathByte >> 6) + 1); + const childHashBytes = ((parseInt(c.raw_hex?.slice(2, 4), 16) || 0) >> 6) + 1; const childRegion = c.observer_id ? (observers.find(o => o.id === c.observer_id)?.iata || '') : ''; let childPath = []; try { childPath = JSON.parse(c.path_json || '[]'); } catch {} @@ -1060,7 +1058,7 @@ ${timeAgo(c.timestamp)} ${truncate(c.hash || '', 8)} ${size}B - ${childHashBytes !== null ? childHashBytes : '—'} + ${childHashBytes} ${typeName} ${truncate(obsName(c.observer_id), 16)} ${childPathStr} @@ -1083,8 +1081,7 @@ const typeName = payloadTypeName(p.payload_type); const typeClass = payloadTypeColor(p.payload_type); const size = p.raw_hex ? Math.floor(p.raw_hex.length / 2) : 0; - const rawPathByte = p.raw_hex ? parseInt(p.raw_hex.slice(2, 4), 16) : NaN; - const hashBytes = isNaN(rawPathByte) ? null : ((rawPathByte >> 6) + 1); + const hashBytes = ((parseInt(p.raw_hex?.slice(2, 4), 16) || 0) >> 6) + 1; const pathStr = renderPath(pathHops, p.observer_id); const detail = getDetailPreview(decoded); return ` @@ -1092,7 +1089,7 @@ ${timeAgo(p.timestamp)} ${truncate(p.hash || String(p.id), 8)} ${size}B - ${hashBytes !== null ? hashBytes : '—'} + ${hashBytes} ${typeName} ${truncate(obsName(p.observer_id), 16)} ${pathStr}