@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
15 lines (14 loc) • 478 B
TypeScript
/**
* Validates whether a given string is a valid URL.
*
* This function attempts to create a new `URL` object from the input string.
* If the input is not a valid URL, it throws an error and returns `false`.
*
* @param url - The string to validate as a URL.
* @returns `true` if the string is a valid URL, otherwise `false`.
*
* @example
* isURL('https://example.com'); // true
* isURL('not-a-url'); // false
*/
export default function isURL(url: string): boolean;