From 5ea1393a16c0a96f191cfebc1e1d2bf61a4a48da Mon Sep 17 00:00:00 2001 From: remotetohome <178868468+remotetohome@users.noreply.github.com> Date: Thu, 5 Feb 2026 01:35:54 -0600 Subject: [PATCH] Fix IP sorting: push empty/invalid IPs to bottom --- templates/status.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/status.html b/templates/status.html index 112a729..2cc283e 100644 --- a/templates/status.html +++ b/templates/status.html @@ -35,8 +35,8 @@ Connected Peers function ipToNumber(ip) { // Extract IP from formats like "10.9.0.132/32" or "99.92.101.230:56078" - const match = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/); - if (!match) return 0; + const match = (ip || '').trim().match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/); + if (!match) return null; // Empty/invalid IPs will be sorted to bottom return (parseInt(match[1]) << 24) + (parseInt(match[2]) << 16) + (parseInt(match[3]) << 8) + parseInt(match[4]); } @@ -66,6 +66,11 @@ Connected Peers const aValue = getSortValue(a.cells[columnIndex], sortType); const bValue = getSortValue(b.cells[columnIndex], sortType); + // Push null/empty values to bottom regardless of sort direction + if (aValue === null && bValue === null) return 0; + if (aValue === null) return 1; + if (bValue === null) return -1; + let comparison = 0; if (sortType === 'text') { comparison = aValue.localeCompare(bValue);