From 03ee12bda56b5eef69103f97dfceea2d2f15077f Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Thu, 5 Sep 2024 17:01:33 -0400 Subject: [PATCH] [5.x] Private asset container url method should return null (#10769) --- src/Assets/AssetContainer.php | 4 ++++ tests/Assets/AssetContainerTest.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/Assets/AssetContainer.php b/src/Assets/AssetContainer.php index 8322b8b649..29765fce49 100644 --- a/src/Assets/AssetContainer.php +++ b/src/Assets/AssetContainer.php @@ -134,6 +134,10 @@ public function path() */ public function url() { + if ($this->private()) { + return null; + } + $url = rtrim($this->disk()->url('/'), '/'); return ($url === '') ? '/' : $url; diff --git a/tests/Assets/AssetContainerTest.php b/tests/Assets/AssetContainerTest.php index f5e16172bb..10ef45712f 100644 --- a/tests/Assets/AssetContainerTest.php +++ b/tests/Assets/AssetContainerTest.php @@ -144,11 +144,13 @@ public function its_private_if_the_disk_has_no_url() $container = (new AssetContainer)->disk('test'); $this->assertTrue($container->private()); $this->assertFalse($container->accessible()); + $this->assertNull($container->url()); Storage::fake('test', ['url' => '/url']); $this->assertFalse($container->private()); $this->assertTrue($container->accessible()); + $this->assertEquals('/url', $container->url()); } #[Test]