
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
ip-address-validation
Advanced tools
Validate IPv4 and IPv6 addresses with a fast JavaScript module.
This is a fast module for validating IPv4 and IPv6 addresses.
It's written in JavaScript with extreme efficiency and simplicity.
A complete line-by-line code algorithm explanation is coming soon.
git clone https://github.com/liamloads/javascript-ip-address-validation-module.git
<script src="ip-address-validation.js" type="text/javascript"></script>
<script type="text/javascript">console.log(ipAddressValidation('127.0.0.1'));</script>
cd
npm install ip-address-validation
const ipAddressValidation = require('ip-address-validation');
console.log(ipAddressValidation('127.0.0.1'));
The module function accepts one IPv4 or IPv6 address argument.
IPv4 addresses are accepted with dotted x.x.x.x
formatting without base conversion or subnet masking.
IPv6 addresses are accepted with long x:x:x:x:x:x:x:x
, short x::x
or translated x:x:x:x:x:x:x.x.x.x
formatting without prefixes.
The return value is a number
with an IP address version of either 4
or 6
.
If the argument isn't a valid IPv4 or IPv6 address, the return value is false
.
console.log(ipAddressValidation('127.0.0.1'));
// 4
console.log(ipAddressValidation(' 127.0.0.1'));
// false
console.log(ipAddressValidation('127.0.0.1/32'));
// false
console.log(ipAddressValidation('127.0.0.1000'));
// false
console.log(ipAddressValidation('::1'));
// 6
console.log(ipAddressValidation(':::1'));
// false
console.log(ipAddressValidation('0000:0000:0000:0000:0000:0000:0000:0001'));
// 6
console.log(ipAddressValidation('0000:0000:0000:0001::127.0.0.1'));
// 6
console.log(ipAddressValidation('0000:0000:0000:0000:0001::127.0.0.1000'));
// false
console.log(ipAddressValidation('AB:ab::cd:CD'));
// 6
FAQs
Validate IPv4 and IPv6 addresses with a fast JavaScript module.
The npm package ip-address-validation receives a total of 0 weekly downloads. As such, ip-address-validation popularity was classified as not popular.
We found that ip-address-validation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.