Socket
Socket
Sign inDemoInstall

is-my-ip-valid

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-my-ip-valid

A small lib to validate IP addresses.


Version published
Weekly downloads
713K
increased by0.33%
Maintainers
1
Install size
20.6 kB
Created
Weekly downloads
 

Readme

Source

Is my IP valid

A small lib to validate IP addresses.

Installation

npm install --save is-my-ip-valid

Usage

const validator = require('is-my-ip-valid')
const validate = validator()
const validate4 = validator({ version: 4 })
const validate6 = validator({ version: 6 })

console.log(validate('127.0.0.1'))
//=> true

console.log(validate4('127.0.0.1'))
//=> true

console.log(validate6('127.0.0.1'))
//=> false

console.log(validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true

console.log(validate4('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> false

console.log(validate6('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true

Acknowledgements

The code is mostly based on this wonderful library: beaugunderson/ip-address

All regexes used are audited for catastrophic backtracking by this module: substack/safe-regex

FAQs

Last updated on 01 Mar 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc