Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
tldtools
Advanced tools
Readme
This module provides TLD domain extraction and resolution services. It's useful if you need to extract semantically meaningful tokens from a URL.
npm install tldtools
var tldtools = require('tldtools').init();
or
var tldtools = require('tldtools');
tldtools.init(function() {
console.log('success!');
});
The first time tldtools is loaded it will attempt to call out to https://publicsuffix.org/list/public_suffix_list.dat
to retrieve the latest TLD list. This file is parsed, normalised and stored in /.tlds
. To override this outbound call and look locally, place your
own overriding file in /effective_tld_names.dat
To force a cache refresh of TLD data in your own running application, you must provide a hook which calls tldtools.tldCacheRefresh
Extracts tld, domain and subdomain parts from the provided fqdn (supports FQDNs names and URIs).
Based on John Kurkowski's tldextract python library. https://github.com/john-kurkowski/tldextract
Returns an object keyed by
example URL that makes no sense :
var tldtools = require('tldtools').init(function() {
console.log(tldtools.extract('http://bob:funk@wagga.wagga.funkjazz.gov.au:1234/?go=abc&123'));
});
Returns...
{ subdomain: 'wagga.wagga',
domain: 'funkjazz',
tld: 'gov.au',
url_tokens:
{ protocol: 'http:',
slashes: true,
auth: 'bob:funk',
host: 'bob:funk@wagga.wagga.funkjazz.gov.au:1234',
port: '1234',
hostname: 'wagga.wagga.funkjazz.gov.au',
href: 'http://bob:funk@wagga.wagga.funkjazz.gov.au:1234/?go=abc&123',
search: '?go=abc&123',
query: 'go=abc&123',
pathname: '/' },
inspect: { useful: [Function], getDomain: [Function] } }
Rebuilds the local in-memory cache from either the remote TLD datasource, or a local copy of effective_tld_names.dat
if the local copy exists.
function()
function(errorMessage)
Attempts to perform a whois lookup for the provided fqdn (supprts FQDNs and URI's)
Available options (opts)
function(whoisData, fqdn, cbPassthrough)
function(errorMessage, fqdn, cbPassthrough)
failure callbackeg:
tldtools.whois(
'github.com',
{
'onSuccess' : function(whoisData, fqdn, cbPassthrough) {
console.log(whoisData);
console.log(fqdn + ' ultimate success!');
console.log(cbPassthrough);
},
'onFail' : function(errorMessage, fqdn, cbPassthrough) {
console.log(errorMessage);
console.log(fqdn + ' WHOIS FAILED');
console.log(cbPassthrough);
}
},
'cbPassthrough' : ['some data']
});
FAQs
Extracts a domain into its component parts (node-url wrapper), performs domain inspection functions
The npm package tldtools receives a total of 47 weekly downloads. As such, tldtools popularity was classified as not popular.
We found that tldtools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.