Skip to content

Commit

Permalink
parsed-url: fixed warning in the case of url without host
Browse files Browse the repository at this point in the history
  • Loading branch information
janreges committed Dec 17, 2023
1 parent 658b649 commit 284e844
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Crawler/ParsedUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static function parse(string $url, ?ParsedUrl $baseUrl = null): self
$fragment = $parsedUrl['fragment'] ?? null;
$extension = ($path && str_contains($path, '.')) ? pathinfo($path, PATHINFO_EXTENSION) : null;
$domain2ndLevel = null;
if (preg_match('/([a-z0-9\-]+\.[a-z][a-z0-9]{0,10})$/i', $host, $matches) === 1) {
if ($host && preg_match('/([a-z0-9\-]+\.[a-z][a-z0-9]{0,10})$/i', $host, $matches) === 1) {
$domain2ndLevel = $matches[1];
};

Expand Down

0 comments on commit 284e844

Please sign in to comment.