Socket
Book a DemoInstallSign in
Socket

domain-regex

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domain-regex

A regular expression for valid domains.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Domain Regex

Build Status

A regular expression for matching valid domain names. This regex seeks to support all domains with TLDs listed on publicsuffix.org including IDNs.

In the near future this will be likely moved to https://github.com/regexps.

Installation

npm i --save domain-regex

Usage

var domain = require('domain-regex');

domain().test('example.aerodrome.aero') // => true
domain().test('a.sub.domain.org')       // => true
domain().test('invalid_domain')         // => false

IDN Support

This regex requires any Unicode character to be converted to its ASCII equivalent. This can be done with a library like punycode.js.

var domainRegex = require('domain-regex');
var punyCode = require('punycode');

domainRegex().test(punycode.toASCII('岡山.jp')) // => true

Acknowledgements

License

MIT

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Crafted with <3 by John Otander.

Keywords

domain

FAQs

Package last updated on 14 Dec 2014

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