Socket
Socket
Sign inDemoInstall

isurl

Package Overview
Dependencies
1
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-alpha3 to 1.0.0-alpha4

30

index.js

@@ -7,3 +7,3 @@ "use strict";

function isURL(url)
function isURL(url, supportIncomplete/*=false*/)
{

@@ -15,13 +15,19 @@ // Native implementation

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 (!("searchParams" in url)) return false;
if (!("hash" in url)) return false;
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.searchParams) === false) return false;
// TODO :: write a separate isURLSearchParams ?
}

@@ -28,0 +34,0 @@ // Shimmed implementation

{
"name": "isurl",
"description": "Checks whether a value is a WHATWG URL.",
"version": "1.0.0-alpha3",
"version": "1.0.0-alpha4",
"license": "MIT",

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

"isomorphic-url": "^1.0.0-alpha12",
"mocha": "^3.2.0"
"mocha": "^3.2.0",
"whatwg-url": "^4.7.0"
},

@@ -17,0 +18,0 @@ "engines": {

# isurl [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
> Checks whether a value is a WHATWG [`URL`](https://developer.mozilla.org/en/docs/Web/API/URL).

@@ -20,9 +21,17 @@

const isURL = require('isurl');
const assert = require('assert');
assert.equal(isURL('http://domain/'), false);
assert.equal(isURL(new URL('http://domain/')), true);
isURL('http://domain/'); //-> false
isURL(new URL('http://domain/')); //-> true
```
Optionally, acceptance can be extended to incomplete `URL` implementations that lack `searchParams` (which are common in many modern web browsers):
```js
const url = new URL('http://domain/?query');
console.log(url.searchParams); //-> undefined
isURL(url, true); //-> true
```
[npm-image]: https://img.shields.io/npm/v/isurl.svg

@@ -29,0 +38,0 @@ [npm-url]: https://npmjs.org/package/isurl

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