Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down