Commit 7f465f30 authored by Taylor Otwell's avatar Taylor Otwell

Refactoring URL class.

parent 3c216d89
...@@ -9,9 +9,10 @@ class URL { ...@@ -9,9 +9,10 @@ class URL {
* *
* @param string $url * @param string $url
* @param bool $https * @param bool $https
* @param bool $asset
* @return string * @return string
*/ */
public static function to($url = '', $https = false) public static function to($url = '', $https = false, $asset = false)
{ {
if (filter_var($url, FILTER_VALIDATE_URL) !== false) if (filter_var($url, FILTER_VALIDATE_URL) !== false)
{ {
...@@ -20,10 +21,9 @@ class URL { ...@@ -20,10 +21,9 @@ class URL {
$base = Config::get('application.url').'/'.Config::get('application.index'); $base = Config::get('application.url').'/'.Config::get('application.index');
if ($https and strpos($base, 'http://') === 0) $base = ($asset) ? str_replace('/'.Config::get('application.index'), '', $base) : $base;
{
$base = 'https://'.substr($base, 7); $base = ($https and strpos($base, 'http://') === 0) ? 'https://'.substr($base, 7) : $base;
}
return $base.'/'.ltrim($url, '/'); return $base.'/'.ltrim($url, '/');
} }
...@@ -48,7 +48,7 @@ class URL { ...@@ -48,7 +48,7 @@ class URL {
*/ */
public static function to_asset($url) public static function to_asset($url)
{ {
return str_replace('/'.Config::get('application.index'), '', static::to($url, Request::is_secure())); return static::to($url, Request::is_secure(), true);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment