Skip to content

Commit

Permalink
[5.x] Private asset container url method should return null (#10769)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Sep 5, 2024
1 parent adc37d2 commit 03ee12b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Assets/AssetContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public function path()
*/
public function url()
{
if ($this->private()) {
return null;
}

$url = rtrim($this->disk()->url('/'), '/');

return ($url === '') ? '/' : $url;
Expand Down
2 changes: 2 additions & 0 deletions tests/Assets/AssetContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 03ee12b

Please sign in to comment.