Nerfing Powerful Megalomaniacs

npm

Need private packages and team management tools?Check out npm Orgs. »

get-urls

9.2.0 • Public • Published

get-urls Build Status

Get all URLs in a string

The URLs will be normalized.

Don't use this for any kind of security-related validation.

Install

$ npm install get-urls

Usage

const getUrls = require('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: true

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

install

npm i get-urls

Downloadsweekly downloads

39,623

version

9.2.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability