Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@helpdotcom/is

Package Overview
Dependencies
Maintainers
19
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helpdotcom/is - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 2017-05-17, Version 2.2.1 (Stable)
* [[977aec635a](https://git.help.com/common-backend/is/commit/977aec635a)] - index: add isIp() (Christy Leung) [CHAT-2328](https://helpdotcom.atlassian.net/browse/CHAT-2328)
# 2017-04-19, Version 2.2.0 (Stable)

@@ -2,0 +6,0 @@

@@ -5,2 +5,4 @@ 'use strict'

const tld = require('tldjs')
const net = require('net')
const ipAddress = require('ip-address')
const emailRE = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}$/

@@ -59,1 +61,10 @@ const EMAIL_NAME_RE = new RegExp(

}
exports.isIp = function isIp(s) {
if (typeof s !== 'string') return false
if (net.isIP(s) !== 0) return true
const IpAddressType = s.indexOf(':') > -1
? ipAddress.Address6 : ipAddress.Address4
const address = new IpAddressType(s)
return address.isValid()
}

3

package.json
{
"name": "@helpdotcom/is",
"version": "2.2.0",
"version": "2.2.1",
"description": "isDate, isUUID, and isEmail for use with help-gen",

@@ -14,2 +14,3 @@ "main": "index.js",

"dependencies": {
"ip-address": "~5.8.8",
"tldjs": "~1.6.2"

@@ -16,0 +17,0 @@ },

@@ -65,3 +65,9 @@ # is

### isIp(s)
* `s` [`<String>`][] The url to test.
Returns `true` if `s` is a valid ip. Otherwise, returns `false`.
## Author

@@ -68,0 +74,0 @@

@@ -92,1 +92,18 @@ 'use strict'

})
test('isIp', (t) => {
const is = helpIs.isIp
t.equal(is('172.0.0.1'), true)
t.equal(is('0.0.0.0'), true)
t.equal(is('2001:0db8:85a3:0000:0000:8a2e:0370:7334'), true)
t.equal(is('192.168.100.0/22'), true)
t.equal(is('172.255.255.255'), true)
t.equal(is('10.0.0.0'), true)
t.equal(is('173.a.0.0'), false)
t.equal(is('204.0.113.4255'), false)
t.equal(is('hellohello'), false)
t.equal(is(' '), false)
t.equal(is('SELECT\0x33:~;_-\\\\'), false)
t.equal(is(1234), false)
t.end()
})
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc