Skip to content

Instantly share code, notes, and snippets.

View bstees's full-sized avatar

Brent Stees bstees

  • Catalyte
View GitHub Profile
@bstees
bstees / abbreviate_ipv6.js
Last active July 13, 2019 03:13
Abbreviates full IPv6 addresses by removing the leading "0" and collapsing longest consecutive run of 16-bit zeros down to "::".
/* Abbreviate full ipv6 address
* By Brent Stees (http://facebook.com/brent.stees), 2014
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */
function abbreviate_ipv6(ip){
if(ip.indexOf("::") == -1) {
// needs to be abbreviated
// remove leading zeros