Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-valid-hostname

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-valid-hostname

Validate hostname based on RFC-1123

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52K
increased by4.65%
Maintainers
1
Weekly downloads
 
Created
Source

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') // 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('8.8.8.8') // true
isValidHostname('127.0.0.1') // true
isValidHostname('exa_mple.com') // false
isValidHostname('-example.com') // false
isValidHostname('example.com:3000') // false
isValidHostname('8.8.8.8:3000') // false

View more examples.

Test

npm test

FAQ

  • Q: Why are numbers allowed in top-level domain?

    • A: Numbers in TLD are allowed under RFC-1123. See this answer for more information.

License

MIT

Keywords

FAQs

Package last updated on 08 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc