psl
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
PSL (Public Suffix List) is a JavaScript-based domain name parser leveraging the Public Suffix List, a cross-vendor initiative providing a comprehensive list of domain name suffixes. This library allows developers to parse domain names accurately to extract information like top-level domain (TLD), second-level domain (SLD), the full domain name, and any optional subdomains. This tool serves as a vital resource in various software but was primarily intended to aid browser manufacturers' needs.
To employ PSL in your projects, follow these steps:
npm install --save psl
In your JavaScript file, require the 'psl' module and use its functions. Here are examples of how to use different functions:
var psl = require('psl');
var parsed = psl.parse('www.google.com');
console.log(parsed.tld); // 'com'
console.log(parsed.sld); // 'google'
console.log(parsed.domain); // 'google.com'
console.log(parsed.subdomain); // 'www'
var psl = require('psl');
var domain = psl.get('www.example.COM');
console.log(domain); // 'example.com'
var psl = require('psl');
var isValid = psl.isValid('google.com');
console.log(isValid); // true
The documentation for PSL can be found directly in its README file on the GitHub repository. It provides a comprehensive guide on installing and using this module, including function usage and code examples. The Public Suffix List, on which psl is based, is also explained in detail on publicsuffix.org.