1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

solution for only remove the tld if it is at the end of the site name

o check if tld is at the end of the site name and if so remove it
o added corresponding test
This commit is contained in:
Erik | Sobit
2022-11-02 11:53:04 +01:00
parent fbde8c54fa
commit 2d429c353d
2 changed files with 13 additions and 1 deletions

View File

@@ -208,7 +208,10 @@ public function getSiteUrl($directory)
$directory = $this->host(getcwd());
}
$directory = str_replace('.'.$tld, '', $directory); // Remove .tld from sitename if it was provided
$length = strlen('.'.$tld);
if (substr($directory, -$length) === '.'.$tld) {
$directory = substr($directory, 0, -$length); // Remove .tld from sitename if it was provided
}
if (! $this->parked()->merge($this->links())->where('site', $directory)->count() > 0) {
throw new DomainException("The [{$directory}] site could not be found in Valet's site list.");