MDN self-hosted library · e01.org

publicSuffix.isKnownSuffix()

Returns true if the hostname is a known public suffix (eTLD) in the Public Suffix List.

Open notebook · 1 cells webextension-api-function upstream source

Returns true if the hostname is a known public suffix (eTLD) in the Public Suffix List.

Syntax

let result = browser.publicSuffix.isKnownSuffix(hostname)

Parameters

  • hostname
  • : string. The hostname to check.

Return value

true if hostname is a known public suffix, false otherwise.

Throws an error if hostname is not a valid hostname.

Examples

Check whether a string is a known public suffix:

browser.publicSuffix.isKnownSuffix("com"); // true
browser.publicSuffix.isKnownSuffix("co.uk"); // true
browser.publicSuffix.isKnownSuffix("github.io"); // true
browser.publicSuffix.isKnownSuffix("example.com"); // false
browser.publicSuffix.isKnownSuffix("localhost"); // false

Browser compatibility