-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getRegisterable() doesn't always return the registerable domain only #1
Comments
@artyuum please not the library constructor is expecting a domain or hostname as the first argument and not a URL. |
You can try and use it this way: $domain = new Domain(parse_url('https://www.facebook.com', PHP_URL_HOST));
$this->assertEquals('www.facebook.com', $domain->get());
$this->assertEquals('com', $domain->getTLD());
$this->assertEquals('com', $domain->getSuffix());
$this->assertEquals('facebook.com', $domain->getRegisterable());
$this->assertEquals('facebook', $domain->getName());
$this->assertEquals('www', $domain->getSub());
$this->assertEquals(true, $domain->isKnown());
$this->assertEquals(true, $domain->isICANN());
$this->assertEquals(false, $domain->isPrivate());
$this->assertEquals(false, $domain->isTest());
$domain = new Domain(parse_url('https://facebook.com', PHP_URL_HOST));
$this->assertEquals('facebook.com', $domain->get());
$this->assertEquals('com', $domain->getTLD());
$this->assertEquals('com', $domain->getSuffix());
$this->assertEquals('facebook.com', $domain->getRegisterable());
$this->assertEquals('facebook', $domain->getName());
$this->assertEquals('', $domain->getSub());
$this->assertEquals(true, $domain->isKnown());
$this->assertEquals(true, $domain->isICANN());
$this->assertEquals(false, $domain->isPrivate());
$this->assertEquals(false, $domain->isTest()); |
Yup, that's the workaround I found in order to strip the "http(s)://" part. The problem is that no error/exception were returned. Why not use |
I think detecting if the value is a URL, hostname, or domain might be out of scope, and add unwanted complexity. I can add a small validation for strings that starts with |
Agreed. |
@artyuum, I just pushed a fix, and released a new tag (0.2.2). |
Thank you. |
Hi, I have had the case of domains starting with "http" (exemple : httpmydomain.com) so the check would fail even if the domain is perfectly valid. I guess you should check at least for "http:" and "https:" What do you think ? |
This has been fixed and released 🥳 Dont hesitate to reopen issue if you still encounter same problem after upgrading. |
Steps to reproduce
The text was updated successfully, but these errors were encountered: