Skip to content

Commit

Permalink
Merge pull request #39 from wilr/patch-2
Browse files Browse the repository at this point in the history
Handle case when body element is not found.
  • Loading branch information
zanderwar committed Mar 18, 2019
2 parents 9b5c2f0 + 1210aca commit 2c9286b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Forms/GoogleSearchPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ public function __construct($name, $title, $page, simple_html_dom $domParser)
$renderedTitle = $domParser->find('title', 0);

$body = $domParser->find('body', 0);
foreach ($body->find('header,footer,nav') as $header) {
$header->outertext = '';

if ($body) {
foreach ($body->find('header,footer,nav') as $header) {
$header->outertext = '';
}
}

$firstParagraph = $domParser->find('p', 0);
Expand Down

0 comments on commit 2c9286b

Please sign in to comment.