get-urls
Get all URLs in a string
Last updated 4 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install get-urls 
SYNC missed versions from official npm registry.

get-urls

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: 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

Current Tags

  • 11.0.0                                ...           latest (4 years ago)

22 Versions

  • 11.0.0                                ...           4 years ago
  • 10.0.1                                ...           5 years ago
  • 10.0.0                                ...           6 years ago
  • 9.2.1                                ...           6 years ago
  • 9.2.0                                ...           6 years ago
  • 9.1.0                                ...           7 years ago
  • 9.0.0                                ...           7 years ago
  • 8.0.0                                ...           8 years ago
  • 7.2.0                                ...           8 years ago
  • 7.0.0                                ...           9 years ago
  • 6.0.0                                ...           9 years ago
  • 5.0.1                                ...           10 years ago
  • 5.0.0                                ...           11 years ago
  • 4.0.1                                ...           11 years ago
  • 4.0.0                                ...           11 years ago
  • 3.0.0                                ...           11 years ago
  • 2.0.0                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (3)
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |