mirror of
https://github.com/ngoduykhanh/wireguard-ui
synced 2026-03-14 21:45:43 +01:00
Fix IP sorting: push empty/invalid IPs to bottom
This commit is contained in:
parent
1ccdf70bdf
commit
5ea1393a16
1 changed files with 7 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue