https://github.com/masylum/tldextract
Extract domain, subdomain and tld from a url
https://github.com/masylum/tldextract
Last synced: 9 months ago
JSON representation
Extract domain, subdomain and tld from a url
- Host: GitHub
- URL: https://github.com/masylum/tldextract
- Owner: masylum
- Created: 2011-09-17T21:50:42.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2021-11-19T14:26:31.000Z (over 4 years ago)
- Last Synced: 2025-07-07T01:17:56.970Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 127 KB
- Stars: 38
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tldextract
Accurately separates the gTLD or ccTLD (generic or country code
top-level domain) from the registered domain and subdomains of a URL.
## How does it work?
``` javascript
var tldextract = require('tldextract');
tldextract('http://forums.news.cnn.com/', function (err, obj) {
// obj: {subdomain: 'forums.news', domain: 'cnn', tld: 'com'}
});
tldextract('http://ye.ye.ye.ye/', function (err, obj) {
// obj: {subdomain: 'ye', domain: 'ye', tld: 'ye.ye'}
});
```
## tests
``` bash
make
```
## Disclaimer
This module is a port of the python module [tldextract](https://github.com/john-kurkowski/tldextract).