Skip to content

Commit

Permalink
Add "noindex,follow" for /Search
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jan 25, 2024
1 parent 5bd1c2c commit 8943885
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/Providers/SeoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ private function metaRobots(): string
if ($request->getHost() === '4programmers.dev') {
return 'noindex,nofollow';
}
if ($request->getRequestUri() === '/Forum/Interesting') {
if ($request->getPathInfo() === '/Search') {
return 'noindex,follow';
}
if ($request->getPathInfo() === '/Forum/Interesting') {
return 'noindex,nofollow';
}
return 'index,follow';
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/Seo/Meta/Fixture/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function assertNoIndexable(string $uri): void
$this->assertMetaRobots($uri, 'noindex,nofollow');
}

function assertCrawlable(string $uri): void
{
$this->assertMetaRobots($uri, 'noindex,follow');
}

function assertMetaRobots(string $uri, string $metaRobots): void
{
Assert::assertSame($metaRobots, $this->metaProperty('robots', $uri));
Expand Down
10 changes: 9 additions & 1 deletion tests/Unit/Seo/Meta/MetaRobotsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function homepage()
*/
public function userTags()
{
$this->assertNoIndexable('/Forum/Interesting');
$this->assertNoIndexable('/Forum/Interesting?query');
}

/**
Expand All @@ -40,4 +40,12 @@ public function developerEnvironment()
{
$this->assertNoIndexable('http://4programmers.dev/');
}

/**
* @test
*/
public function search()
{
$this->assertCrawlable('/Search?query');
}
}

0 comments on commit 8943885

Please sign in to comment.