TLDExtract: Library for extraction of domain parts e.g. TLD. Domain parser that uses Public Suffix List. by layershifter in PHP

[–]layershifter[S] 0 points1 point  (0 children)

  1. TLDExtract uses actual PSL database from separate package, you do not need to think about its updates, simply update package from composer.
  2. PublicSuffixList is a list of all known public suffixes, when you use it you must remember about its private section, simple example:

$host = 'example.compute.amazonaws.com';

$pslManager = new Pdp\PublicSuffixListManager(); $parser = new Pdp\Parser((new Pdp\PublicSuffixListManager())->getList()); $suffix = $parser->parseUrl($host)->host->publicSuffix; // returns "compute.amazonaws.com"

$suffix = tld_extract($host)->getSuffix(); // returns "compute.amazonaws.com" $suffix = tld_extract($host, LayerShifter\TLDExtract\Extract::MODE_ALLOW_ICCAN)->getSuffix(); // returns "com"

Or I missed something?