A relatively small and fast port of the Public Suffix List to JavaScript/TypeScript.
mpsl.get(domain)
returns the registrable part of domain
.
import * as mpsl from 'mpsl';
console.log(mpsl.get('www.test.ac.jp')); // test.ac.jp
mpsl.get
does not throw an exception and returns null
on invalid input.
The Public Suffix List was initiated by Mozilla and is maintained by the community. I appreciate their great work.
The Public Suffix List is available at the official website or the GitHub repository. It is distributed under MPL-2.0.
mpsl depends on punycode.js by Mathias Bynens and mpsl's UMD variant is bundled with it. I appreciate his great work.
The source code of punycode.js is available at the GitHub repository. It is distributed under MIT.