UNPKG

@the-node-forge/url-validator

Version:

A lightweight and efficient library for validating URLs. It ensures that URLs are correctly formatted and provides an optional feature to check whether a URL is live by sending an HTTP request. This package is designed for web applications, APIs, and serv

13 lines (12 loc) 288 B
export async function isUrlLive(url) { try { if (!/^https?:\/\//i.test(url)) { url = `https://${url}`; } const response = await fetch(url, { mode: 'no-cors' }); return response !== undefined; } catch { return false; } }