Get all urls in a string
Clone or download
Latest commit 82685ae Sep 17, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Meta tweaks and cleanup Dec 2, 2017
.gitattributes Require Node.js 6 Sep 6, 2018
.gitignore Meta tweaks and cleanup Dec 2, 2017
.npmrc Meta tweaks and cleanup Dec 2, 2017
.travis.yml Require Node.js 6 Sep 6, 2018
fixture.txt find urls beginning with www Jun 8, 2016
index.js Require Node.js 6 Sep 6, 2018
license Meta tweaks and cleanup Dec 2, 2017
package.json 8.0.0 Sep 6, 2018
readme.md Update readme.md Sep 18, 2018
test.js Require Node.js 6 Sep 6, 2018

readme.md

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 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[]

Exclude URLs that match URLs in the given array.

Related

License

MIT © Sindre Sorhus