Skip to content

Commit

Permalink
Merge branch '50-incorrect-results' of github.com:vormkracht10/larave…
Browse files Browse the repository at this point in the history
…l-seo-scanner into 50-incorrect-results
  • Loading branch information
Baspa committed Jan 25, 2024
2 parents 2597a4b + 52f98f8 commit 7766de8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/Checks/Meta/DescriptionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public function check(Response $response, Crawler $crawler): bool
public function getDescriptionContent(Crawler $crawler): ?string
{
$tags = ['description', 'og:description', 'twitter:description'];

foreach ($tags as $tag) {
$property = $tag === 'og:description' ? 'property' : 'name';

/** @var \DOMElement $node */
$node = $crawler->filterXPath("//meta[@{$property}=\"{$tag}\"]")->getNode(0);

if ($node instanceof \DOMElement && $node->hasAttribute('content')) {
return $node->getAttribute('content');
}
}

return null;
}

public function validateContent(Crawler $crawler): bool
{
$content = $this->getDescriptionContent($crawler);
return !empty($content);

return ! empty($content);
}

public function isDescriptionSet(Crawler $crawler): bool
{
return $this->getDescriptionContent($crawler) !== null;
Expand Down
2 changes: 1 addition & 1 deletion tests/Checks/Meta/DescriptionCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
$crawler->addHtmlContent(Http::get('vormkracht10.nl')->body());

$this->assertFalse($check->check(Http::get('vormkracht10.nl'), $crawler));
});
});

0 comments on commit 7766de8

Please sign in to comment.