2.3.0 • Published 9 years ago

domain-name-parser v2.3.0

Weekly downloads
1,190
License
MIT
Repository
github
Last release
9 years ago

node-domain-name-parser

A simple parser that breaks apart a domain name into its components

build status

install

npm

npm install domain-name-parser

usage

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

2.3.0

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.6

10 years ago

0.0.5

11 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago

0.0.0

12 years ago