Commit 6a9cc481 authored by Taylor Otwell's avatar Taylor Otwell

fix handling of hash Urls.

parent c0a80d13
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
- Added "$hidden" static variable to the base Eloquent model. - Added "$hidden" static variable to the base Eloquent model.
- Added "sync" method to has_many_and_belongs_to Eloquent relationship. - Added "sync" method to has_many_and_belongs_to Eloquent relationship.
- Improved View performance by only loading contents from file once. - Improved View performance by only loading contents from file once.
- Fix handling of URLs beginning with has in URL::to.
<a name="upgrade-3.2"></a> <a name="upgrade-3.2"></a>
## Upgrading From 3.1 ## Upgrading From 3.1
......
...@@ -117,7 +117,13 @@ class URL { ...@@ -117,7 +117,13 @@ class URL {
*/ */
public static function to($url = '', $https = false) 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'); $root = static::base().'/'.Config::get('application.index');
...@@ -310,4 +316,15 @@ class URL { ...@@ -310,4 +316,15 @@ class URL {
return trim($uri, '/'); 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;
}
} }
\ No newline at end of file
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