# is-domain-name

> Validate Domain Names as outlined by RFC 2181

Latest version **1.0.1** (published 2016-07-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install is-domain-name
pnpm add is-domain-name
yarn add is-domain-name
bun add is-domain-name
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-07-25 |
| First published | 2016-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/is-domain-name) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Emil Bay |
| Maintainers | emilbay |
| Keywords | is, domain, name, rfc2181, dns, hostname, host |

## Links

- npm: https://www.npmjs.com/package/is-domain-name
- Repository: https://github.com/emilbayes/is-domain-name
- Homepage: https://github.com/emilbayes/is-domain-name#readme
- Issues: https://github.com/emilbayes/is-domain-name/issues
- npm.io page: https://npm.io/package/is-domain-name

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

- 1.0.1 (latest) — 2016-07-25
- 1.0.0 — 2016-07-25

## README

# `is-domain-name`

> Validate Domain Names as outlined by RFC 2181


## Install

```sh
npm install is-domain-name
```

## Usage

Domain names are composed of labels interleaved with a separator (`.`).
Domain as allowed a total length of 255 chars including separators.
Labels should be between 1 and 63 octets.

Labels allows domains to form a hierarchy, with the right most label acting
as the root. The leftmost label is often called the TLD (Top-Level Domain),
the 2nd leftmost informally called the domain and any label to the right of
those called subdomains.

A common domain with only a single label is `localhost`.

This module checks the following:

* The domain is no longer than 255 chars
* The domain is at least 2 chars. Even though `a` is technically allowed, this module does not allow it
* Labels are between 1 and 63 chars
* Labels start and end with alpha-numeric chars, allowing dashes in between
* An optional root dot can be allowed with a flag, eg. `example.com.`

```js
const assert = require('assert')
const isDomainName = require('is-domain-name')

assert.ok(isDomainName('localhost'))
assert.notOk(isDomainName('-.-'))
```

## API

### isDomainName(domainName, rootDot)
#### domainName

Type: `String`

#### rootDot
Type: `Boolean`<br>
Default: `false`

Whether or not to validate for a trailing dot, signifying the root

## Related

* [`is-http-url`](http://github.com/emilbayes/is-http-url)

## License

[ISC](LICENSE.md)

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