safer-url
v1.0.1
Published
Wrapper around the native `URL` type but returns `null` for invalid URLs instead of throwing an error.
Readme
safer-url
Wrapper around the native URL type but returns null for invalid URLs instead of throwing an error.
Installation
Install safer-url with your favorite package manager:
npm install safer-urlUsage
import safeURL from 'safer-url';
console.log(safeURL('https://tunnel.dev')); // new URL(...)
console.log(safeURL('invalid')); // null