From 7bed4e0b01242bd0d265c173fdb06934fd1994c7 Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Tue, 27 Sep 2022 21:44:04 +0200 Subject: [PATCH] Fixed #44327: use prefix for url when generating url for scoped disk --- src/Illuminate/Filesystem/FilesystemAdapter.php | 4 ++++ tests/Filesystem/FilesystemAdapterTest.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 40d0234db8e7..91ea80259205 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -620,6 +620,10 @@ public function writeStream($path, $resource, array $options = []) */ public function url($path) { + if (isset($this->config['prefix'])) { + $path = $this->concatPathToUrl($this->config['prefix'], $path); + } + $adapter = $this->adapter; if (method_exists($adapter, 'getUrl')) { diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index 8fe056078ab5..e0d045d38e06 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -564,4 +564,11 @@ public function testProvidesTemporaryUrlsForAdapterWithoutTemporaryUrlSupport() $this->assertFalse($filesystemAdapter->providesTemporaryUrls()); } + + public function testPrefixesUrls() + { + $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['url' => 'https://example.org/', 'prefix' => 'images']); + + $this->assertEquals('https://example.org/images/picture.jpeg', $filesystemAdapter->url('picture.jpeg')); + } }