is-valid-hostname
Validate hostname in JavaScript based on RFC-1123.
Demo
https://lab.miguelmota.com/is-valid-hostname
Install
npm install is-valid-hostname
Usage
const isValidHostname = require('is-valid-hostname')
isValidHostname('localhost')
isValidHostname('example.com')
isValidHostname('foo.example.com')
isValidHostname('bar.foo.example.com')
isValidHostname('exa-mple.co.uk')
isValidHostname('xn--80ak6aa92e.com')
isValidHostname('9gag.com')
isValidHostname('8.8.8.8')
isValidHostname('127.0.0.1')
isValidHostname('exa_mple.com')
isValidHostname('-example.com')
isValidHostname('example.com:3000')
isValidHostname('8.8.8.8:3000')
View more examples.
Test
npm test
FAQ
License
MIT