Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js |
— | — | @@ -236,6 +236,38 @@ |
237 | 237 | ['204.204.132.158'], |
238 | 238 | ['247.240.82.209'] |
239 | 239 | ]; |
| 240 | +var ipv4CIDR = [ |
| 241 | + // Some randomly generated fake IPs |
| 242 | + ['45.238.27.109/36'], |
| 243 | + ['170.38.91.162/36'], |
| 244 | + ['247.240.82.209/36'], |
| 245 | + ['204.204.132.158/24'], |
| 246 | + ['170.38.91.162/24'] |
| 247 | +]; |
| 248 | +var ipv4CIDRSorted = [ |
| 249 | + // Sort order should go octet by octet |
| 250 | + ['45.238.27.109/36'], |
| 251 | + ['170.38.91.162/24'], |
| 252 | + ['170.38.91.162/36'], |
| 253 | + ['204.204.132.158/24'], |
| 254 | + ['247.240.82.209/36'] |
| 255 | +]; |
| 256 | +var ipv4Mixed = [ |
| 257 | + // Some randomly generated fake IPs |
| 258 | + ['45.238.27.109'], |
| 259 | + ['170.38.91.162'], |
| 260 | + ['247.240.82.209'], |
| 261 | + ['204.204.132.158/24'], |
| 262 | + ['170.38.91.162/24'] |
| 263 | +]; |
| 264 | +var ipv4MixedSorted = [ |
| 265 | + // Sort order should go octet by octet |
| 266 | + ['45.238.27.109'], |
| 267 | + ['170.38.91.162'], |
| 268 | + ['170.38.91.162/24'], |
| 269 | + ['204.204.132.158/24'], |
| 270 | + ['247.240.82.209'] |
| 271 | +]; |
240 | 272 | |
241 | 273 | tableTest( |
242 | 274 | 'Bug 17141: IPv4 address sorting', |
— | — | @@ -257,7 +289,28 @@ |
258 | 290 | $table.find( '.headerSort:eq(0)' ).click().click(); |
259 | 291 | } |
260 | 292 | ); |
| 293 | +tableTest( |
| 294 | + 'Bug 34475: IPv4/CIDR address sorting', |
| 295 | + ['IP'], |
| 296 | + ipv4CIDR, |
| 297 | + ipv4CIDRSorted, |
| 298 | + function( $table ) { |
| 299 | + $table.tablesorter(); |
| 300 | + $table.find( '.headerSort:eq(0)' ).click(); |
| 301 | + } |
| 302 | +); |
261 | 303 | |
| 304 | +tableTest( |
| 305 | + 'Bug 34475: Mixed IPv4 and IP/CIDR address sorting', |
| 306 | + ['IP'], |
| 307 | + ipv4Mixed, |
| 308 | + ipv4MixedSorted, |
| 309 | + function( $table ) { |
| 310 | + $table.tablesorter(); |
| 311 | + $table.find( '.headerSort:eq(0)' ).click(); |
| 312 | + } |
| 313 | +); |
| 314 | + |
262 | 315 | var umlautWords = [ |
263 | 316 | // Some words with Umlauts |
264 | 317 | ['Günther'], |
Index: trunk/phase3/RELEASE-NOTES-1.20 |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | preference for the non-default skin to look at something using the default skin. |
21 | 21 | * (bug 31417) New ID mw-content-text around the actual page text, without categories, |
22 | 22 | contentSub, ... The same div often also contains the class mw-content-ltr/rtl. |
| 23 | +* (bug 34475) Add support for IP/CIDR notation to tablesorter |
23 | 24 | |
24 | 25 | === Bug fixes in 1.20 === |
25 | 26 | * (bug 30245) Use the correct way to construct a log page title. |
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js |
— | — | @@ -484,7 +484,7 @@ |
485 | 485 | } |
486 | 486 | ts.rgx = { |
487 | 487 | IPAddress: [ |
488 | | - new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/) |
| 488 | + new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}(\/\d{1,3})?$/) |
489 | 489 | ], |
490 | 490 | currency: [ |
491 | 491 | new RegExp( /^[£$€?.]/), |
— | — | @@ -767,9 +767,15 @@ |
768 | 768 | }, |
769 | 769 | format: function( s ) { |
770 | 770 | var a = s.split( '.' ), |
771 | | - r = '', |
772 | | - l = a.length; |
773 | | - for ( var i = 0; i < l; i++ ) { |
| 771 | + r = ''; |
| 772 | + if( a.length == 4 ) { |
| 773 | + var cidr = a[3].split('/'); |
| 774 | + if (cidr.length > 1 ) { |
| 775 | + a[3] = cidr[0]; |
| 776 | + a[4] = cidr[1]; |
| 777 | + } else a[4] = '000'; |
| 778 | + } |
| 779 | + for ( var i = 0; i < a.length; i++ ) { |
774 | 780 | var item = a[i]; |
775 | 781 | if ( item.length == 1 ) { |
776 | 782 | r += '00' + item; |