Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johno/domain-regex
A regular expression for most valid domains (including the latest TLDs)
https://github.com/johno/domain-regex
Last synced: 3 months ago
JSON representation
A regular expression for most valid domains (including the latest TLDs)
- Host: GitHub
- URL: https://github.com/johno/domain-regex
- Owner: johno
- License: mit
- Created: 2014-12-14T21:32:22.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-27T07:14:55.000Z (almost 10 years ago)
- Last Synced: 2024-10-12T18:22:19.644Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 38
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Domain Regex
[![Build Status](https://travis-ci.org/johnotander/domain-regex.svg?branch=master)](https://travis-ci.org/johnotander/domain-regex)
A regular expression for matching valid domain names. This regex seeks to support all
domains with TLDs listed on
[publicsuffix.org](https://publicsuffix.org/list/effective_tld_names.dat) including
[IDNs](http://en.wikipedia.org/wiki/Internationalized_domain_name).In the near future this will be likely moved to .
## Installation
```
npm i --save domain-regex
```## Usage
```javascript
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](https://github.com/bestiejs/punycode.js).```javascript
var domainRegex = require('domain-regex');
var punyCode = require('punycode');domainRegex().test(punycode.toASCII('岡山.jp')) // => true
```## Acknowledgements
* Regex adapted from .
## License
MIT
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull RequestCrafted with <3 by [John Otander](http://johnotander.com).