From ae5ca802f4234ccff74e7f908bba25ee56189af5 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 9 Oct 2014 16:57:56 +0100 Subject: [PATCH] [#152] HP devices with port names "D##" not sorted by portsort.js In naturalsort there is handling for Float, Decimal and Scientific notation. This looks for numbers like: '10.04f','10.039F','10.038d','1.528535047e5' It was breaking port sorting for ports named like "D1", "D10" etc. Have removed support for sorting these numbers as it's unlikely we need that in Netdisco, for now. --- Netdisco/Changes | 6 ++++++ Netdisco/share/public/javascripts/portsort.js | 6 +++--- Netdisco/t/10-sort_port.t | 1 + Netdisco/t/html/portsort.html | 12 ++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index e613cb73..18fd0d7a 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,9 @@ +2.029012 - 2014-10-09 + + [BUG FIXES] + + * [#152] HP devices with port names "D##" not sorted by portsort.js + 2.029011 - 2014-10-07 [BUG FIXES] diff --git a/Netdisco/share/public/javascripts/portsort.js b/Netdisco/share/public/javascripts/portsort.js index 4f6b5ef8..2de54fc4 100644 --- a/Netdisco/share/public/javascripts/portsort.js +++ b/Netdisco/share/public/javascripts/portsort.js @@ -24,7 +24,7 @@ * See: http://js-naturalsort.googlecode.com/svn/trunk/naturalSort.js */ function portSort (a, b) { - var re = /(^(-?\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, + var re = /(^0x[0-9a-f]+$|[0-9]+)/gi, // string regex sre = /(^[ ]*|[ ]*$)/g, // octal regex @@ -56,8 +56,8 @@ function portSort (a, b) { oFyNcL += ''; } - if (oFxNcL < oFyNcL) return -1; - if (oFxNcL > oFyNcL) return 1; + if (oFxNcL < oFyNcL) { return -1; } + if (oFxNcL > oFyNcL) { return 1; } } return 0; diff --git a/Netdisco/t/10-sort_port.t b/Netdisco/t/10-sort_port.t index 59f3aebf..0ec24bf4 100644 --- a/Netdisco/t/10-sort_port.t +++ b/Netdisco/t/10-sort_port.t @@ -13,5 +13,6 @@ BEGIN { is(sort_port(1,1), 0, 'number - same values'); is(sort_port('1:2','1:10'), -1, 'colon number (Extreme) - first lesser'); +is(sort_port('D1','D10'), -1, 'HP - simple letter and number [#152]'); done_testing; diff --git a/Netdisco/t/html/portsort.html b/Netdisco/t/html/portsort.html index abf8e53e..213bdd76 100644 --- a/Netdisco/t/html/portsort.html +++ b/Netdisco/t/html/portsort.html @@ -146,6 +146,18 @@ ],[ '1:1','1:2','1:10','1:11' ],'Extreme'); + wrapTest( + [ + 'D10','D11','D2','D1', 'A30', 'A3' + ],[ + 'A3', 'A30', 'D1','D2','D10','D11' + ],'HP A & D'); + wrapTest( + [ + 'B10','B11','B2','B1', 'A30', 'A3' + ],[ + 'A3', 'A30', 'B1','B2','B10','B11' + ],'HP A & B'); wrapTest( [ '10GigabitEthernet1/1/12',