Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Private asset container url method should return null #10769

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading