/usr/share/javascript/ipaddr/ipaddr.min.js is in libjs-ipaddr 0.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 | (function(){var e,t,n,r,i,s,o,u;t={},u=this,typeof module!="undefined"&&module!==null&&module.exports?module.exports=t:u.ipaddr=t,o=function(e,t,n,r){var i,s;if(e.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");i=0;while(r>0){s=n-r,s<0&&(s=0);if(e[i]>>s!==t[i]>>s)return!1;r-=n,i+=1}return!0},t.subnetMatch=function(e,t,n){var r,i,s,o,u;n==null&&(n="unicast");for(r in t){i=t[r],toString.call(i[0])!=="[object Array]"&&(i=[i]);for(o=0,u=i.length;o<u;o++){s=i[o];if(e.match.apply(e,s))return r}}return n},t.IPv4=function(){function e(e){var t,n,r;if(e.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");for(n=0,r=e.length;n<r;n++){t=e[n];if(!(0<=t&&t<=255))throw new Error("ipaddr: ipv4 octet is a byte")}this.octets=e}return e.prototype.kind=function(){return"ipv4"},e.prototype.toString=function(){return this.octets.join(".")},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.match=function(e,t){if(e.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return o(this.octets,e.octets,8,t)},e.prototype.SpecialRanges={broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],"private":[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]]},e.prototype.range=function(){return t.subnetMatch(this,this.SpecialRanges)},e.prototype.toIPv4MappedAddress=function(){return t.IPv6.parse("::ffff:"+this.toString())},e}(),n="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp("^"+n+"\\."+n+"\\."+n+"\\."+n+"$","i"),longValue:new RegExp("^"+n+"$","i")},t.IPv4.parser=function(e){var t,n,i,s,o;return n=function(e){return e[0]==="0"&&e[1]!=="x"?parseInt(e,8):parseInt(e)},(t=e.match(r.fourOctet))?function(){var e,r,s,o;s=t.slice(1,6),o=[];for(e=0,r=s.length;e<r;e++)i=s[e],o.push(n(i));return o}():(t=e.match(r.longValue))?(o=n(t[1]),function(){var e,t;t=[];for(s=e=0;e<=24;s=e+=8)t.push(o>>s&255);return t}().reverse()):null},t.IPv6=function(){function e(e){var t,n,r;if(e.length!==8)throw new Error("ipaddr: ipv6 part count should be 8");for(n=0,r=e.length;n<r;n++){t=e[n];if(!(0<=t&&t<=65535))throw new Error("ipaddr: ipv6 part should fit to two octets")}this.parts=e}return e.prototype.kind=function(){return"ipv6"},e.prototype.toString=function(){var e,t,n,r,i,s,o;i=function(){var e,n,r,i;r=this.parts,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(t.toString(16));return i}.call(this),e=[],n=function(t){return e.push(t)},r=0;for(s=0,o=i.length;s<o;s++){t=i[s];switch(r){case 0:t==="0"?n(""):n(t),r=1;break;case 1:t==="0"?r=2:n(t);break;case 2:t!=="0"&&(n(""),n(t),r=3);break;case 3:n(t)}}return r===2&&(n(""),n("")),e.join(":")},e.prototype.toByteArray=function(){var e,t,n,r,i;e=[],i=this.parts;for(n=0,r=i.length;n<r;n++)t=i[n],e.push(t>>8),e.push(t&255);return e},e.prototype.toNormalizedString=function(){var e;return function(){var t,n,r,i;r=this.parts,i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.toString(16));return i}.call(this).join(":")},e.prototype.match=function(e,t){if(e.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return o(this.parts,e.parts,16,t)},e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[new e([100,65435,0,0,0,0,0,0]),96],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],reserved:[[new e([8193,3512,0,0,0,0,0,0]),32]]},e.prototype.range=function(){return t.subnetMatch(this,this.SpecialRanges)},e.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},e.prototype.toIPv4Address=function(){var e,n,r;if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");return r=this.parts.slice(-2),e=r[0],n=r[1],new t.IPv4([e>>8,e&255,n>>8,n&255])},e}(),i="(?:[0-9a-f]+::?)+",s={"native":new RegExp("^(::)?("+i+")?([0-9a-f]+)?(::)?$","i"),transitional:new RegExp("^((?:"+i+")|(?:::)(?:"+i+")?)"+(""+n+"\\."+n+"\\."+n+"\\."+n+"$"),"i")},e=function(e,t){var n,r,i,s,o;if(e.indexOf("::")!==e.lastIndexOf("::"))return null;n=0,r=-1;while((r=e.indexOf(":",r+1))>=0)n++;e[0]===":"&&n--,e[e.length-1]===":"&&n--,o=t-n,s=":";while(o--)s+="0:";return e=e.replace("::",s),e[0]===":"&&(e=e.slice(1)),e[e.length-1]===":"&&(e=e.slice(0,-1)),function(){var t,n,r,s;r=e.split(":"),s=[];for(t=0,n=r.length;t<n;t++)i=r[t],s.push(parseInt(i,16));return s}()},t.IPv6.parser=function(t){var n,r;if(t.match(s["native"]))return e(t,8);if(n=t.match(s.transitional)){r=e(n[1].slice(0,-1),6);if(r)return r.push(parseInt(n[2])<<8|parseInt(n[3])),r.push(parseInt(n[4])<<8|parseInt(n[5])),r}return null},t.IPv4.isIPv4=t.IPv6.isIPv6=function(e){return this.parser(e)!==null},t.IPv4.isValid=t.IPv6.isValid=function(e){try{return new this(this.parser(e)),!0}catch(t){return!1}},t.IPv4.parse=t.IPv6.parse=function(e){var t;t=this.parser(e);if(t===null)throw new Error("ipaddr: string is not formatted like ip address");return new this(t)},t.isValid=function(e){return t.IPv6.isValid(e)||t.IPv4.isValid(e)},t.parse=function(e){if(t.IPv6.isIPv6(e))return t.IPv6.parse(e);if(t.IPv4.isIPv4(e))return t.IPv4.parse(e);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},t.process=function(e){var t;return t=this.parse(e),t.kind()==="ipv6"&&t.isIPv4MappedAddress()?t.toIPv4Address():t}}).call(this);
|