fix: 修复“检测文件地址并根据情况转换为文件系统地址”url为null情况报错问题

This commit is contained in:
2025-08-26 14:53:17 +08:00
parent 2a9c3332f7
commit 0b13ec05dc

View File

@@ -153,8 +153,12 @@ if (!function_exists('get_filesystem_url')) {
* @param string $disk 磁盘配置 key * @param string $disk 磁盘配置 key
* @return string * @return string
*/ */
function get_filesystem_url(string $url, string $disk): string function get_filesystem_url(string|null $url, string $disk): string
{ {
if (is_null($url)) {
return '';
}
if (\think\helper\Str::startsWith($url, ['http://', 'https://', '//'])) { if (\think\helper\Str::startsWith($url, ['http://', 'https://', '//'])) {
return $url; return $url;
} }
@@ -171,8 +175,12 @@ if (!function_exists('url_filesystem_detect')) {
* @param string $url 文件地址 * @param string $url 文件地址
* @return string * @return string
*/ */
function url_filesystem_detect(string $url): string function url_filesystem_detect(string|null $url): string
{ {
if (is_null($url)) {
return '';
}
$idx = strrpos($url, '.'); $idx = strrpos($url, '.');
if ($idx === false) { if ($idx === false) {
return $url; return $url;