diff --git a/src/Embed.php b/src/Embed.php index b197cb68..af5dc992 100644 --- a/src/Embed.php +++ b/src/Embed.php @@ -77,7 +77,14 @@ public static function create($url, array $config = null, DispatcherInterface $d $to = preg_replace('|^(\w+://)|', '', rtrim($info->url, '/')); if ($from !== $to && empty($info->code)) { - return self::process(Url::create($info->url), $config, $dispatcher); + + //accept new result if valid + try { + return self::process(Url::create($info->url), $config, $dispatcher); + } catch (\Exception $e) { + return $info; + } + } return $info; @@ -114,7 +121,7 @@ private static function process(Url $url, array $config, DispatcherInterface $di if (Adapters\Webpage::check($response)) { return new Adapters\Webpage($response, $config, $dispatcher); } - + if ($response->getError() === null) { $exception = new Exceptions\InvalidUrlException(sprintf("Invalid url '%s' (Status code %s)", (string) $url, $response->getStatusCode())); } else {