Skip to content

Commit a73d122

Browse files
authored
strip domain in setRoute() (#5903)
1 parent 05e7f86 commit a73d122

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/app/Library/CrudPanel/CrudPanel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public function getSqlDriverList()
209209
*/
210210
public function setRoute($route)
211211
{
212+
// if the route is a full URL, strip the domain
213+
if (str_starts_with($route, url('/'))) {
214+
$route = substr($route, strlen(url('/')));
215+
}
216+
212217
$this->route = ltrim($route, '/');
213218
}
214219

tests/config/Http/CrudControllerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ public function testSetRoute()
3636
$crudPanel = app('crud');
3737
$crudPanel->setRoute(backpack_url('users'));
3838
$crudPanel->setEntityNameStrings('singular', 'plural');
39-
$this->assertEquals(route('users.index'), $crudPanel->getRoute());
39+
$this->assertEquals(config('backpack.base.route_prefix').'/users', $crudPanel->getRoute());
4040
}
4141

42-
/**
43-
* @group fail
44-
*/
4542
public function testCrudRequestUpdatesOnEachRequest()
4643
{
4744
// create a first request

0 commit comments

Comments
 (0)