# get-urls

> Get all URLs in a string

Latest version **12.1.0** (published 2023-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-urls
pnpm add get-urls
yarn add get-urls
bun add get-urls
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 12.1.0 |
| Published | 2023-08-15 |
| First published | 2014-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16 |
| Dependencies | 3 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 372 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | get, urls, url, extract, find, scrape, text, string |

## Links

- npm: https://www.npmjs.com/package/get-urls
- Repository: https://github.com/sindresorhus/get-urls
- Homepage: https://github.com/sindresorhus/get-urls#readme
- Issues: https://github.com/sindresorhus/get-urls/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/get-urls

## Dependencies (3)

- [super-regex](https://npm.io/package/super-regex.md) ^0.2.0
- [normalize-url](https://npm.io/package/normalize-url.md) ^8.0.0
- [url-regex-safe](https://npm.io/package/url-regex-safe.md) ^4.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 12.1.0 (latest) — 2023-08-15
- 12.0.0 — 2023-07-15
- 11.0.0 — 2022-01-15
- 10.0.1 — 2021-10-09
- 10.0.0 — 2020-08-29
- 9.2.1 — 2020-06-28
- 9.2.0 — 2019-10-18
- 9.1.0 — 2019-04-15
- 9.0.0 — 2019-02-20
- 8.0.0 — 2018-09-06
- 7.2.0 — 2017-12-04
- 7.0.0 — 2017-01-20
- 6.0.0 — 2017-01-20
- 5.0.1 — 2016-06-08
- 5.0.0 — 2015-06-22
- … 9 more at https://npm.io/package/get-urls/versions

## README

# get-urls

> Get all URLs in a string

The URLs will be [normalized](https://github.com/sindresorhus/normalize-url).

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

Please note the [known limitation](https://github.com/niftylettuce/url-regex-safe#limitations). You can work around this by setting `requireSchemeOrWww` to `true`.

## Install

```sh
npm install get-urls
```

## Usage

```js
import getUrls from '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](https://github.com/sindresorhus/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

- [get-urls-cli](https://github.com/sindresorhus/get-urls-cli) - CLI for this module
- [linkify-urls](https://github.com/sindresorhus/linkify-urls) - Linkify URLs in text

---
_Source: https://npm.io/package/get-urls · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
