fix handling of hash Urls.

This commit is contained in:
Taylor Otwell
2012-04-02 13:02:49 -05:00
parent c0a80d132f
commit 6a9cc48164
2 changed files with 19 additions and 1 deletions

View File

@@ -117,7 +117,13 @@ class URL {
*/
public static function to($url = '', $https = false)
{
if (filter_var($url, FILTER_VALIDATE_URL) !== false) return $url;
// If the given URL is already valid or begins with a hash, we'll just return
// the URL unchanged since it is already well formed. Otherwise we will add
// the base URL of the application and return the full URL.
if (static::valid($url) or starts_with($url, '#'))
{
return $url;
}
$root = static::base().'/'.Config::get('application.index');
@@ -310,4 +316,15 @@ class URL {
return trim($uri, '/');
}
/**
* Determine if the given URL is valid.
*
* @param string $url
* @return bool
*/
public static function valid($url)
{
return filter_var($url, FILTER_VALIDATE_URL) !== false;
}
}