Skip to content

Instantly share code, notes, and snippets.

View yaoelvon's full-sized avatar

Alex Feng yaoelvon

  • China
View GitHub Profile
@yaoelvon
yaoelvon / abbreviate_ipv6.js
Created July 13, 2019 03:13 — forked from bstees/abbreviate_ipv6.js
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