Socket
Socket
Sign inDemoInstall

isurl

Package Overview
Dependencies
3
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

61

index.js

@@ -21,39 +21,46 @@ "use strict";

const isURL = (url, supportIncomplete/*=false*/) =>
const isURL = (url, supportIncomplete=false) =>
{
if (!isObject(url)) return false;
// Native implementation in older browsers
if (!hasToStringTag && toString.call(url) === urlClass) return true;
if (!(href in url)) return false;
if (!(protocol in url)) return false;
if (!(username in url)) return false;
if (!(password in url)) return false;
if (!(hostname in url)) return false;
if (!(port in url)) return false;
if (!(host in url)) return false;
if (!(pathname in url)) return false;
if (!(search in url)) return false;
if (!(hash in url)) return false;
if (supportIncomplete !== true)
if (!isObject(url))
{
if (!isObject(url.searchParams)) return false;
return false;
}
else if (!hasToStringTag && toString.call(url) === urlClass)
{
// Native implementation in older browsers -- unlikely, but thorough
return supportIncomplete;
}
else if
(!(
href in url &&
protocol in url &&
username in url &&
password in url &&
hostname in url &&
port in url &&
host in url &&
pathname in url &&
search in url &&
hash in url
))
{
return false;
}
else if (!supportIncomplete)
{
// TODO :: write a separate isURLSearchParams ?
return isObject(url.searchParams);
}
else
{
return true;
}
};
return true;
}
isURL.lenient = url => isURL(url, true);
isURL.lenient = url =>
{
return isURL(url, true);
};
module.exports = isURL;
{
"name": "isurl",
"description": "Checks whether a value is a WHATWG URL.",
"version": "1.0.0",
"version": "2.0.0",
"license": "MIT",

@@ -9,13 +9,13 @@ "author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)",

"dependencies": {
"has-to-string-tag-x": "^1.2.0",
"has-to-string-tag-x": "^1.4.1",
"is-object": "^1.0.1"
},
"devDependencies": {
"chai": "^4.0.2",
"mocha": "^3.4.2",
"semver": "^5.3.0",
"universal-url": "^1.0.0"
"chai": "^4.2.0",
"incomplete-url": "^2.0.0",
"mocha": "^5.2.0",
"universal-url": "^2.0.0"
},
"engines": {
"node": ">= 4"
"node": ">= 6"
},

@@ -22,0 +22,0 @@ "scripts": {

@@ -1,2 +0,2 @@

# isurl [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
# isurl [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]

@@ -6,3 +6,3 @@ > Checks whether a value is a WHATWG [`URL`](https://developer.mozilla.org/en/docs/Web/API/URL).

Works cross-realm/iframe and despite @@toStringTag.
Works cross-realm/iframe and despite `Symbol.toStringTag`.

@@ -12,3 +12,3 @@

[Node.js](http://nodejs.org/) `>= 4` is required. To install, type this at the command line:
[Node.js](http://nodejs.org/) `>= 6` is required. To install, type this at the command line:
```shell

@@ -39,4 +39,6 @@ npm install isurl

[npm-image]: https://img.shields.io/npm/v/isurl.svg
[npm-url]: https://npmjs.org/package/isurl
[npm-url]: https://npmjs.com/package/isurl
[travis-image]: https://img.shields.io/travis/stevenvachon/isurl.svg
[travis-url]: https://travis-ci.org/stevenvachon/isurl
[greenkeeper-image]: https://badges.greenkeeper.io/stevenvachon/isurl.svg
[greenkeeper-url]: https://greenkeeper.io/
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