<?php
declare(strict_types = 1);

namespace Embed\Detectors;

use Psr\Http\Message\UriInterface;

class Redirect extends Detector
{
    public function detect(): ?UriInterface
    {
        $document = $this->extractor->getDocument();
        $value = $document->select('.//meta', ['http-equiv' => 'refresh'])->str('content');

        return $value ? $this->extract($value) : null;
    }

    private function extract(string $value): ?UriInterface
    {
        if (preg_match('/url=(.+)$/i', $value, $match)) {
            return $this->extractor->resolveUri($match[1]);
        }

        return null;
    }
}

<?php
declare(strict_types = 1);

namespace Embed\Detectors;

use Psr\Http\Message\UriInterface;

class Redirect extends Detector
{
    public function detect(): ?UriInterface
    {
        $document = $this->extractor->getDocument();
        $value = $document->select('.//meta', ['http-equiv' => 'refresh'])->str('content');

        return $value ? $this->extract($value) : null;
    }

    private function extract(string $value): ?UriInterface
    {
        if (preg_match('/url=(.+)$/i', $value, $match)) {
            return $this->extractor->resolveUri(trim($match[1], '\'"'));
        }

        return null;
    }
}

Fix for quotation marks in redirect URL
Fix for quotation marks in redirect URL

Some websites use quotation marks around the url= query in the meta-refresh tag. Example: https://presse.stuttgart-tourist.de/die-weihnachtsmaerkte-in-der-region-stuttgart
<meta HTTP-EQUIV="refresh" content="0;url='https://presse.stuttgart-tourist.de/die-weihnachtsmaerkte-in-der-region-stuttgart?PageSpeed=noscript'" />
Those have to be trimmed or an error (GuzzleHttp\Psr7\Exception\MalformedUriException: A relative URI must not have a path beginning with a segment containing a colon) is triggered