Skip to content

Commit

Permalink
Paginated homepage /?page=2 is canonical
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jan 24, 2024
1 parent 9cab745 commit 91fdaf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/Http/Middleware/RedirectToCanonicalUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ public function handle(Request $request, callable $next): HttpFoundation\Respons

private function hasTrailingSlash(Request $request): bool
{
if ($request->getRequestUri() === '/') {
$uri = $request->getPathInfo();
if ($uri === '/') {
return false;
}
return \str_ends_with($request->getPathInfo(), '/');
return \str_ends_with($uri, '/');
}

private function hasTrailingQuerySeparator(Request $request): bool
Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/Canonical/TrailingSlash/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function homepage()
$this->assertCanonicalGet('/');
}

/**
* @test
*/
public function homepagePage()
{
$this->assertCanonicalGet('/?page=2');
}

/**
* @test
*/
Expand Down

0 comments on commit 91fdaf2

Please sign in to comment.