mirror of
https://github.com/laravel/laravel.git
synced 2025-02-20 11:53:14 +08:00
fix handling of hash Urls.
This commit is contained in:
parent
c0a80d132f
commit
6a9cc48164
@ -24,6 +24,7 @@
|
||||
- Added "$hidden" static variable to the base Eloquent model.
|
||||
- Added "sync" method to has_many_and_belongs_to Eloquent relationship.
|
||||
- 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>
|
||||
## Upgrading From 3.1
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user