1.0.5 • Published 5 months ago

@redlotus/get-urls v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

RedLotus-Logo-Dark RedLotus-Logo-Light

Redlotus fork for adding CommonJS support

get-urls

Get all URLs in a string

The URLs will be normalized.

Do not use this for any kind of security-related validation.

Please note the known limitation. You can work around this by setting requireSchemeOrWww to true.

Install

npm install @redlotus/get-urls

yarn add @redlotus/get-urls

Usage

import { getUrls } from '@redlotus/get-urls';

const text = 'Lorem ipsum dolor sit amet, //sindresorhus.com consectetuer adipiscing http://yeoman.io elit.';

getUrls(text);
//=> Set {'http://sindresorhus.com', 'http://yeoman.io'}

API

getUrls(text, options?)

Returns a Set of URLs.

text

Type: string

options

Type: object

All the normalize-url options in addition to:

extractFromQueryString

Type: boolean\ Default: false

Extract URLs that appear as query parameters in the found URLs.

exclude

Type: string[]\ Default: []

Exclude URLs that match URLs in the given array.

requireSchemeOrWww

Type: boolean\ Default: false

Require URLs to have a scheme or leading www. to be considered an URL. When false, matches against a list of valid TLDs, so it will match URLs like unicorn.education.

Does not affect URLs in query parameters if using the extractFromQueryString option.

Related

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago