diff --git a/src/helpers.php b/src/helpers.php index 9c3b75cd..1774bb5f 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -61,7 +61,7 @@ if (! function_exists('tenant_route')) { { // replace first occurance of hostname fragment with $domain $url = route($route, $parameters, $absolute); - $hostname = parse_url($url, PHP_URL_HOST); + $hostname = parse_url($url, PHP_URL_HOST) ?? ''; $position = strpos($url, $hostname); return substr_replace($url, $domain, $position, strlen($hostname)); diff --git a/tests/Features/RedirectTest.php b/tests/Features/RedirectTest.php index 4f7f77a1..6ffbe9ef 100644 --- a/tests/Features/RedirectTest.php +++ b/tests/Features/RedirectTest.php @@ -42,5 +42,6 @@ class RedirectTest extends TestCase $this->assertSame('http://foo.localhost/abcdef/as/df', tenant_route('foo.localhost', 'foo', ['a' => 'as', 'b' => 'df'])); $this->assertSame('http://foo.localhost/abcdef', tenant_route('foo.localhost', 'foo', [])); + $this->assertSame('foo.localhost/abcdef', tenant_route('foo.localhost', 'foo', [], false)); } }