diff --git a/app/Helper/LinkAce.php b/app/Helper/LinkAce.php index 56837131..4ed52797 100644 --- a/app/Helper/LinkAce.php +++ b/app/Helper/LinkAce.php @@ -12,20 +12,26 @@ class LinkAce /** * Get the title of an HTML page b * @param string $url - * @return null|string|string[] + * @return string|string[] */ public static function getTitleFromURL(string $url) { - $fp = file_get_contents($url); + $fail_return = parse_url($url, PHP_URL_HOST); + + try { + $fp = file_get_contents($url); + } catch (\Exception $e) { + return $fail_return; + } if (!$fp) { - return null; + return $fail_return; } $res = preg_match("/