From c072fe905bebabb77b7ffe69369c12aae647968a Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Wed, 21 May 2025 22:53:10 +0200 Subject: [PATCH 1/4] if prefix is set as empty string dont add start forward slash --- 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 46e23072c58d..275abc279a3c 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -725,7 +725,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 4e81c5eebd394c4d330c8b7a0e7cc32fb00b5d7b Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Wed, 21 May 2025 23:03:56 +0200 Subject: [PATCH 2/4] pint --- 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 275abc279a3c..937f29b32fa6 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -725,7 +725,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']) && ! empty($this->config['prefix'])) { $path = $this->concatPathToUrl($this->config['prefix'], $path); } From 56dcb7641154930d0e733bd830b51b5f525d796a Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Wed, 21 May 2025 23:54:48 +0200 Subject: [PATCH 3/4] 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 937f29b32fa6..146abc4e0e2c 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -725,7 +725,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); } @@ -847,6 +847,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, '/'); } From 185d40f037f4bc14ded56fd0639ae73f4cf6a15b Mon Sep 17 00:00:00 2001 From: Omar Tuffaha Date: Thu, 22 May 2025 09:09:54 +0200 Subject: [PATCH 4/4] dont trim by default can break simple slash only paths --- src/Illuminate/Filesystem/FilesystemAdapter.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 146abc4e0e2c..00760bafb611 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -847,12 +847,8 @@ public function temporaryUploadUrl($path, $expiration, array $options = []) */ protected function concatPathToUrl($url, $path) { - if (empty($url)) { - return trim($path, '/'); - } - - if (empty($path)) { - return trim($url, '/'); + if (empty($url) || empty($path)) { + return $url ?: $path; } return rtrim($url, '/').'/'.ltrim($path, '/');