diff --git a/application/config/application.php b/application/config/application.php index 01f07845..8baf172b 100755 --- a/application/config/application.php +++ b/application/config/application.php @@ -15,6 +15,20 @@ return array( 'url' => '', + /* + |-------------------------------------------------------------------------- + | Asset URL + |-------------------------------------------------------------------------- + | + | The base URL used for your application's asset files, if you are serving + | them through a different server or a content delivery network, for + | example. If it's not set, we'll default to the application URL (above). + | Leave off the trailing slash. + | + */ + + 'asset_url' => '', + /* |-------------------------------------------------------------------------- | Application Index diff --git a/laravel/bundle.php b/laravel/bundle.php index 15b9b3da..32965390 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -297,7 +297,7 @@ class Bundle { { if (is_null($bundle)) return static::assets(DEFAULT_BUNDLE); - return ($bundle != DEFAULT_BUNDLE) ? URL::base()."/bundles/{$bundle}/" : URL::base().'/'; + return ($bundle != DEFAULT_BUNDLE) ? "/bundles/{$bundle}/" : '/'; } /** diff --git a/laravel/url.php b/laravel/url.php index ec2de9e5..9c73526e 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -220,6 +220,18 @@ class URL { */ public static function to_asset($url, $https = null) { + + // If the URL is already well-formed, just return it + if (static::valid($url)) return $url; + + // If a base asset URL is defined in the configuration, use that and + // don't try and change links to http/https. + if ($root = Config::get('application.asset_url', false )) { + + return rtrim($root, '/').'/'.ltrim($url, '/'); + + } + if (is_null($https)) $https = Request::secure(); $url = static::to($url, $https);