Skip to content

Commit 0b48361

Browse files
committed
Search: Fixed pagination not considering sub-paths
For #5951 Added test to cover.
1 parent 2de3247 commit 0b48361

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/Search/SearchController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function search(Request $request, SearchResultsFormatter $formatter)
3030
$results = $this->searchRunner->searchEntities($searchOpts, 'all', $page, $count);
3131
$formatter->format($results['results']->all(), $searchOpts);
3232
$paginator = new LengthAwarePaginator($results['results'], $results['total'], $count, $page);
33-
$paginator->setPath('/search');
33+
$paginator->setPath(url('/search'));
3434
$paginator->appends($request->except('page'));
3535

3636
$this->setPageTitle(trans('entities.search_for_term', ['term' => $fullSearchString]));

tests/Search/EntitySearchTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ public function test_bookshelf_search()
3030
public function test_search_shows_pagination()
3131
{
3232
$search = $this->asEditor()->get('/search?term=a');
33-
$this->withHtml($search)->assertLinkExists('/search?term=a&page=2', '2');
33+
$this->withHtml($search)->assertLinkExists(url('/search?term=a&page=2'), '2');
34+
}
35+
36+
public function test_pagination_considers_sub_path_url_handling()
37+
{
38+
$this->runWithEnv(['APP_URL' => 'https://example.com/subpath'], function () {
39+
$search = $this->asEditor()->get('https://example.com/search?term=a');
40+
$this->withHtml($search)->assertLinkExists('https://example.com/subpath/search?term=a&page=2', '2');
41+
});
3442
}
3543

3644
public function test_invalid_page_search()

0 commit comments

Comments
 (0)