🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

goturl

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

goturl

The library that tries to do its best to extract urls from strings.

3.7.0
latest
Version published
Maintainers
0
Created

goturl

NPM version NPM downloads Fastify

goturl - the library that tries to do its best to extract urls from strings.

Installation

yarn add goturl

Usage

import { extractUrl } from 'goturl';

extractUrl("Visit https://example.com for more info");
// => https://example.com

extractUrl("Website: another-one.com");
// => another-one.com

extractUrl("Don't forget about this.com/thing?query=string", { fallbackProtocol: 'https' });
// => https://this.com/thing?query=string

extractUrl("Check out our promotions: http://promotion.com http://promotion.com/real/offer", { getLongestUrl: true });
// => http://promotion.com/real/offer

extractUrl("Quick reminder, check out our websitehttps://hurry.com/mistake", { tryFixProtocol: true });
// => https://hurry.com/mistake

extractUrl("Visit https://example.com/my-(awesome)-path for more info", { includeParentheses: true });
// => https://example.com/my-(awesome)-path

Testing

yarn test

FAQs

Package last updated on 28 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts