A regular expression for most valid domains (including the latest TLDs)
MIT License
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.
npm i --save domain-regex
var domain = require('domain-regex');
domain().test('example.aerodrome.aero') // => true
domain().test('a.sub.domain.org') // => true
domain().test('invalid_domain') // => false
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
MIT
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Crafted with <3 by John Otander.