mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Return full asset URLs
This commit is contained in:
parent
01480432a8
commit
969fca6066
2 changed files with 7 additions and 5 deletions
|
@ -59,7 +59,7 @@ class Application extends IlluminateApplication
|
|||
/**
|
||||
* Get a URL for static file requests.
|
||||
* If this installation of Koel has a CDN_URL configured, use it as the base.
|
||||
* Otherwise, just use a relative '/'.
|
||||
* Otherwise, just use a full URL to the asset.
|
||||
*
|
||||
* @param string $name The additional resource name/path.
|
||||
*
|
||||
|
@ -67,7 +67,9 @@ class Application extends IlluminateApplication
|
|||
*/
|
||||
public function staticUrl($name = null)
|
||||
{
|
||||
return trim(env('CDN_URL'), '/ ').'/'.trim(ltrim($name, '/'));
|
||||
$cdnUrl = trim(env('CDN_URL'), '/ ');
|
||||
|
||||
return $cdnUrl ? $cdnUrl.'/'.trim(ltrim($name, '/')) : trim(asset($name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,8 +11,8 @@ class ApplicationTest extends TestCase
|
|||
{
|
||||
putenv('CDN_URL');
|
||||
|
||||
$this->assertEquals(App::staticUrl(), '/');
|
||||
$this->assertEquals(App::staticUrl('foo.css '), '/foo.css');
|
||||
$this->assertEquals(App::staticUrl(), 'http://localhost/');
|
||||
$this->assertEquals(App::staticUrl('foo.css '), 'http://localhost/foo.css');
|
||||
}
|
||||
|
||||
public function testStaticUrlWithCDN()
|
||||
|
@ -28,7 +28,7 @@ class ApplicationTest extends TestCase
|
|||
putenv('CDN_URL');
|
||||
|
||||
$manifestFile = dirname(__FILE__).'/blobs/rev-manifest.json';
|
||||
$this->assertEquals(App::rev('foo.css', $manifestFile), '/public/build/foo00.css');
|
||||
$this->assertEquals(App::rev('foo.css', $manifestFile), 'http://localhost/public/build/foo00.css');
|
||||
|
||||
putenv('CDN_URL=http://cdn.bar');
|
||||
$this->assertEquals(App::rev('bar.js', $manifestFile), 'http://cdn.bar/public/build/bar00.js');
|
||||
|
|
Loading…
Reference in a new issue