Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

is-valid-hostname

0.1.1 • Public • Published

is-valid-hostname

Validate hostname in JavaScript based on RFC-3696.

Demo

https://lab.miguelmota.com/is-valid-hostname

Install

npm install is-valid-hostname

Usage

const isValidHostname = require('is-valid-hostname')
 
isValidHostname('localhost') // true
isValidHostname('example.com') // true
isValidHostname('foo.example.com') // true
isValidHostname('bar.foo.example.com') // true
isValidHostname('exa-mple.co.uk') // true
isValidHostname('xn--80ak6aa92e.com') // true
isValidHostname('9gag.com') // true
isValidHostname('exa_mple.com') // false
isValidHostname('-example.com') // false
isValidHostname('example.com:3000') // false
isValidHostname('127.0.0.1') // false

View more examples.

Test

npm test

License

MIT

Install

npm i is-valid-hostname

DownloadsWeekly Downloads

261

Version

0.1.1

License

MIT

Unpacked Size

13.2 kB

Total Files

11

Last publish

Collaborators

  • avatar