Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -140,6 +140,10 @@ public function url()

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

if (str_starts_with($url, config('app.url'))) {
$url = substr($url, strlen(config('app.url')));
}

return ($url === '') ? '/' : $url;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Assets/AssetContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ public function it_gets_the_url_from_the_disk_config_when_its_relative()
$this->assertEquals('http://localhost/container', $container->absoluteUrl());
}

#[Test]
public function it_gets_the_url_from_the_disk_config_when_its_app_url()
{
config(['filesystems.disks.test' => [
'driver' => 'local',
'root' => __DIR__.'/__fixtures__/container',
'url' => 'http://localhost/container',
]]);

$container = (new AssetContainer)->disk('test');

$this->assertEquals('/container', $container->url());
$this->assertEquals('http://localhost/container', $container->absoluteUrl());
}

#[Test]
public function its_private_if_the_disk_has_no_url()
{
Expand Down
Loading