More work on parsing endpoints in the body

This commit is contained in:
Lewis Dale committed 2023-03-08 16:07:43 +00:00
1 parent 4eba80387d
commit e5f7595321
2 files changed
+41

No files matched your search

+6
View File
@@ -3,6 +3,7 @@
namespace Lewisdale\Webmentions;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Symfony\Component\DomCrawler\Crawler;
class EndpointParser {
public static function parse(ResponseInterface $response) : string | null
@@ -22,6 +23,11 @@ class EndpointParser {
}
}
if (!$endpoint) {
$doc = new Crawler($response->getContent());
$webmention = $doc->filter('rel="webmention"')->first();
}
if ($endpoint && !str_contains($endpoint, "https://")) {
$res = parse_url($response->getInfo('url'));
$endpoint = $res["scheme"] . "://" . $res["host"] . $endpoint;