tldjs Node.js module written in JavaScript to work against complex domain names, subdomains and well-known TLDs.
Read more about the project on https://www.npmjs.com/tldjs.
Report any issues or questions on https://github.com/oncletom/tld.js
const {parse, tldExists} = require('tldjs');
// Checking only if TLD exists in URL or hostname
// First TLD exists; the second does not.
console.log(tldExists('https://www.bbc'));
console.log(tldExists('tld.unknown'));
// Retrieving hostname related informations of a given URL
parse('http://www.writethedocs.org/conf/eu/2017/');