How to handle localhost and custom hostnames
masterBy default, getDomain and getSubdomain only work with known and valid TLDs. Because localhost is not a registered TLD, these methods will return null for it.
To support custom hostnames or localhost, use tldjs.fromUserSettings() to create a new instance with validHosts defined.
const tldjs = require('tldjs');
// Default behavior
tldjs.getDomain('localhost'); // null
// Custom behavior
const myTldjs = tldjs.fromUserSettings({
validHosts: ['localhost']
});
myTldjs.getDomain('localhost'); // 'localhost'
myTldjs.getSubdomain('vhost.localhost'); // 'vhost'