Module for accessing the publicsuffix.org database for TLDs
Install using npm:
npm install --save publicsuffix-data
Maintains an infrequently-updated copy of the Public Suffix List and an API to query this data.
Other modules for accessing static copies of the data already exist. See these modules if you do not need an automatically-updating database:
const PublicSuffixData = require('publicsuffix-data');
const publicSuffixData = new PublicSuffixData({
tts: timeToStaleInSeconds, // Seconds until the next fetch of data will occur. Defaults to 10 days (864,000).
ttl: timeToLiveInSeconds, // Seconds until old data becomes invalid. Defaults to 30 days (2,592,000).
cache: cacheFileLocation // Defaults to ~/.publicsuffix.org
});
const result = await publicSuffixData.getTLD('foo.example.com');
console.log(result); // "com"