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.1.4 to 2.2.0

4

CHANGELOG.md

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

# 2017-04-19, Version 2.2.0 (Stable)
* [[1f92c5ffa3](https://git.help.com/common-backend/is/commit/1f92c5ffa3)] - **(SEMVER-MINOR)** index: add isUrl() (Stephen Belanger)
# 2017-04-19, Version 2.1.4 (Stable)

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

'use strict'
const url = require('url')
const tld = require('tldjs')

@@ -15,2 +16,7 @@ const emailRE = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}$/

const protocols = new Set([
'http:'
, 'https:'
])
exports.isDate = function isDate(d) {

@@ -47,1 +53,7 @@ if (!d) return false

}
exports.isUrl = function isUrl(s) {
if (typeof s !== 'string') return false
const u = url.parse(s)
return protocols.has(u.protocol) && !!u.host && !!u.path
}

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

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

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

@@ -62,0 +68,0 @@

@@ -73,1 +73,20 @@ 'use strict'

})
test('isUrl', (t) => {
const is = helpIs.isUrl
t.equal(is('http://foo.bar'), true)
t.equal(is('https://foo.bar/baz'), true)
t.equal(is('http://foo.bar.baz/buz'), true)
t.equal(is('http://foo.bar.baz.buz/bux'), true)
t.equal(is('http://foo.bar/baz?buz'), true)
t.equal(is('http://foo.bar/baz#buz'), true)
t.equal(is('http://foo.bar?baz#buz'), true)
t.equal(is('http://foo.bar/baz-buz+bux_bax.bex'), true)
t.equal(is('http://123.456.789.12/'), true)
t.equal(is('http://2001:0db8:85a3:0000:0000:8a2e:0370:7334/'), true)
t.equal(is('internal http://urls.are not allowed'), false)
t.equal(is('invalid://url'), false)
t.equal(is('not a url'), 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