From 98e9255fef7f7c25817b96b21bbae112aa244fba Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Wed, 21 May 2025 23:06:32 +0200 Subject: [PATCH 1/2] check if prefix not empty --- src/Illuminate/Filesystem/FilesystemAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 50ce21f3671d..f71f846bddd4 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -724,7 +724,7 @@ public function writeStream($path, $resource, array $options = []) */ public function url($path) { - if (isset($this->config['prefix'])) { + if (isset($this->config['prefix']) && ! empty($this->config['prefix'])) { $path = $this->concatPathToUrl($this->config['prefix'], $path); } From f7bae8fc7a88cde2e69cff599029ead28d7e77ec Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Wed, 21 May 2025 23:56:28 +0200 Subject: [PATCH 2/2] only concat of both not empty --- src/Illuminate/Filesystem/FilesystemAdapter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index f71f846bddd4..157aab459068 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -724,7 +724,7 @@ public function writeStream($path, $resource, array $options = []) */ public function url($path) { - if (isset($this->config['prefix']) && ! empty($this->config['prefix'])) { + if (isset($this->config['prefix'])) { $path = $this->concatPathToUrl($this->config['prefix'], $path); } @@ -846,6 +846,14 @@ public function temporaryUploadUrl($path, $expiration, array $options = []) */ protected function concatPathToUrl($url, $path) { + if (empty($url)) { + return trim($path, '/'); + } + + if (empty($path)) { + return trim($url, '/'); + } + return rtrim($url, '/').'/'.ltrim($path, '/'); }