isurl

Determine whether a value is a
URLinstance.
Works cross-realm/iframe and despite Symbol.toStringTag.
If you need to support older versions of Node.js (going back to
8.x), use4.xof 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