Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-domain-name-parser
Parse domain name into tld, sld, domain, domainName, host
https://github.com/wankdanker/node-domain-name-parser
Last synced: 2 months ago
JSON representation
Parse domain name into tld, sld, domain, domainName, host
- Host: GitHub
- URL: https://github.com/wankdanker/node-domain-name-parser
- Owner: wankdanker
- Created: 2013-10-30T16:33:38.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-03-02T13:47:19.000Z (almost 9 years ago)
- Last Synced: 2024-04-26T16:04:32.564Z (9 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-domain-name-parser
=======================A simple parser that breaks apart a domain name into its components
[![build status](https://secure.travis-ci.org/wankdanker/node-domain-name-parser.png)](http://travis-ci.org/wankdanker/node-domain-name-parser)
install
=======npm
```bash
npm install domain-name-parser
```usage
=====```javascript
var parse = require('domain-name-parser')
, d = parse('host.subdomain.domain.com')
;console.log(
d.tld //"com" -- the first part on the right
, d.sld //"domain" -- the second part from the right
, d.host //"host" -- the left-most part
, d.domainName //"domain.com" -- always the commonly referred to part (sld + tld)
, d.domain //"subdomain.domain.com" -- everything except the host
, d.level(3) //"subdomain" -- specific domain level part, 1 based (tld is level 1)
);
```api
===* parse(name, opts);
* name - string: the domain name you want to parse
* opts.countryMerge - boolean, default false: if TLD is a country TLD (eg: uk, cn, ru) merge it with the next part and treat that as the TLD
* parse.defaults(opts);
* opts - same as available to parse(). Used as the default for all calls to parse();license
=======MIT