kevindierkx / laravel-domain-parser

Laravel package to ease the interation of PHP Domain parser

Home Page:https://distortedfusion.com/docs/kevindierkx/laravel-domain-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Second Level Domain

paduanton opened this issue · comments

Q A
Version ^5.6

Question

Is there any function I can use to get only the SLD of a \Pdp\Domain object or something like that?

I tried to use de getLabel(2) and getLabel(1), but they do not really worked for me.

Example:

Given the domain paduanton.dev.br or www.paduanton.digital I need a function that returns only paduanton.
Here is a solution to handle this:

$domain = $this->domain->getRegistrableDomain();
$publicSuffix = $this->domain->getPublicSuffix();
$domainSLD = str_replace('.' . $publicSuffix, '', $domain);

That works just fine, but does not look so good. Is there something better I can do with the library?