# is-absolute-url

> Check if a URL is absolute

Latest version **5.0.0** (published 2025-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-absolute-url
pnpm add is-absolute-url
yarn add is-absolute-url
bun add is-absolute-url
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-09-13 |
| First published | 2014-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | url, absolute, relative, is, check |

## Links

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

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2025-09-13
- 4.0.1 — 2021-08-11
- 4.0.0 — 2021-08-10
- 3.0.3 — 2019-09-29
- 3.0.2 — 2019-09-13
- 3.0.1 — 2019-08-18
- 3.0.0 — 2019-04-06
- 2.1.0 — 2016-12-11
- 2.0.0 — 2015-07-03
- 1.0.0 — 2014-08-13
- 0.1.0 — 2014-06-29

## README

# is-absolute-url

> Check if a URL is absolute

## Install

```sh
npm install is-absolute-url
```

## Usage

```js
import isAbsoluteUrl from 'is-absolute-url';

isAbsoluteUrl('https://sindresorhus.com/foo/bar');
//=> true

isAbsoluteUrl('//sindresorhus.com');
//=> false

isAbsoluteUrl('foo/bar');
//=> false

isAbsoluteUrl('javascript:alert(1)');
//=> false

isAbsoluteUrl('javascript:alert(1)', {httpOnly: false});
//=> true
```

## API

### isAbsoluteUrl(url, options?)

#### url

Type: `string`

The URL to check.

#### options

Type: `object`

##### httpOnly

Type: `boolean`\
Default: `true`

Only allow HTTP(S) protocols.

When set to `false`, any valid absolute URL will be accepted, including potentially unsafe protocols like `javascript:`, `ftp:`, `ws:`, etc.

> **Warning**: Setting `httpOnly` to `false` can pose security risks as it will return `true` for URLs with protocols like `javascript:`, `vbscript:`, `data:`, `ftp:`, `ws:`, etc. Only set this to `false` if you understand the implications and have appropriate safeguards in place.

## Related

See [is-relative-url](https://github.com/sindresorhus/is-relative-url) for the inverse.

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