isurl
![Dependency Monitor](https://camo.githubusercontent.com/dd216b98890e0d41228b3fde4ca9940147ee87b412cdae0e8e3ab271fd2f0614/68747470733a2f2f6261646765732e677265656e6b65657065722e696f2f73746576656e766163686f6e2f697375726c2e737667)
Determines whether a value is a WHATWG
URL
.
Works cross-realm/iframe and despite Symbol.toStringTag
.
Installation
Node.js >= 8
is required. To install, type this at the command line:
npm install isurl
Usage
const isURL = require('isurl');
isURL('http://domain/'); //-> false
isURL(new URL('http://domain/')); //-> true
Optionally, acceptance can be extended to incomplete URL
implementations that lack origin
, searchParams
and toJSON
properties (which are common in many modern web browsers):
const url = new URL('http://domain/?query');
console.log(url.searchParams); //-> undefined
isURL.lenient(url); //-> true