npm.io
5.0.0 • Published 2 weeks ago

isurl

Licence
MIT
Version
5.0.0
Deps
3
Size
9 kB
Vulns
0
Weekly
0
Stars
12

isurl NPM Version File Size Build Status Coverage Status

Determine whether a value is a URL instance.

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

If you need to support older versions of Node.js (going back to 8.x), use 4.x of this package.

Install

npm install isurl

Usage

Strict

The standard.

import isURL from 'isurl';

isURL('http://domain/'); //-> false
isURL(new URL('http://domain/')); //-> true
Lenient

Acceptance can be extended to incomplete URL implementations that lack origin, searchParams and toJSON properties (which is common with web browsers from 2021):

import isURL from 'isurl/lenient';

console.log(url.searchParams); //-> undefined

isURL(url); //-> true

Keywords