Fixed regex to parse title from URL to consider possible attributes

This commit is contained in:
Alejandro Celaya 2021-02-03 11:28:40 +01:00
parent 8b54098299
commit 71f85350da

View File

@ -51,7 +51,7 @@ class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
} }
$body = $response->getBody()->__toString(); $body = $response->getBody()->__toString();
preg_match('/<title>(.+)<\/title>/i', $body, $matches); preg_match('/<title[^>]*>(.*?)<\/title>/i', $body, $matches);
return $matches[1] ?? null; return $matches[1] ?? null;
} }