Skip to content

Commit 2c7ecff

Browse files
committed
Make the domain macro replace only the hostname
1 parent c6ea7de commit 2c7ecff

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/Features/CrossDomainRedirect.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function bootstrap(): void
2222
*/
2323
$hostname = parse_url($url, PHP_URL_HOST);
2424

25-
$this->setTargetUrl((string) str($url)->replace($hostname, $domain));
25+
$this->setTargetUrl((string) str($url)->replaceFirst('://' . $hostname, '://' . $domain));
2626

2727
return $this;
2828
});

‎tests/Features/RedirectTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
})->name('home');
2020

2121
Route::get('/redirect', function () {
22-
return redirect()->route('home')->domain('abcd');
22+
return redirect()->route('home', ['email' => 'foo@localhost'])->domain('abcd');
2323
});
2424

2525
$tenant = Tenant::create();
2626
tenancy()->initialize($tenant);
2727

2828
pest()->get('/redirect')
29-
->assertRedirect('http://abcd/foobar');
29+
->assertRedirect('http://abcd/foobar?email=foo%40localhost');
3030
});
3131

3232
test('tenant route helper generates correct url', function () {

0 commit comments

Comments
 (0)