UNPKG

everyutil

Version:

A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.

18 lines (17 loc) 551 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractURLs = void 0; /** * Finds all URLs in a string. * * Example: extractURLs("Visit https://github.com and http://example.com") → ["https://github.com", "http://example.com"] * * @author @dailker * @param {string} str - The input string. * @returns {string[]} Array of URLs found. */ function extractURLs(str) { const regex = /https?:\/\/[^\s/$.?#].[^\s]*/g; return str.match(regex) || []; } exports.extractURLs = extractURLs;