Commit 2f999397 authored by Taylor Otwell's avatar Taylor Otwell

Trim comment bloat from URL class.

parent a2406c01
......@@ -12,9 +12,6 @@ class URL {
*/
public static function to($url = '', $https = false, $asset = false)
{
// ----------------------------------------------------
// Return the URL unchanged if it is already formed.
// ----------------------------------------------------
if (strpos($url, '://') !== false)
{
return $url;
......@@ -22,19 +19,13 @@ class URL {
$base = Config::get('application.url');
// ----------------------------------------------------
// Assets live in the public directory, so we don't
// want to append the index file to the URL if the
// URL is to an asset.
// ----------------------------------------------------
// Assets live in the public directory, so we only want to append
// the index file if the URL is to an asset.
if ( ! $asset)
{
$base .= '/'.Config::get('application.index');
}
// ----------------------------------------------------
// Does the URL need an HTTPS protocol?
// ----------------------------------------------------
if (strpos($base, 'http://') === 0 and $https)
{
$base = 'https://'.substr($base, 7);
......@@ -78,18 +69,13 @@ class URL {
{
if ( ! is_null($route = Route\Finder::find($name)))
{
// ----------------------------------------------------
// Get the first URI assigned to the route.
// ----------------------------------------------------
$uris = explode(', ', key($route));
$uri = substr($uris[0], strpos($uris[0], '/'));
// ----------------------------------------------------
// Replace any parameters in the URI. This allows
// the dynamic creation of URLs that contain parameter
// wildcards.
// ----------------------------------------------------
// Replace any parameters in the URI. This allows the dynamic creation of URLs
// that contain parameter wildcards.
foreach ($parameters as $parameter)
{
$uri = preg_replace('/\(.+?\)/', $parameter, $uri, 1);
......@@ -122,16 +108,10 @@ class URL {
*/
public static function slug($title, $separator = '-')
{
// ----------------------------------------------------
// Remove all characters that are not the separator,
// letters, numbers, or whitespace.
// ----------------------------------------------------
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', Str::lower($title));
// ----------------------------------------------------
// Replace all separator characters and whitespace by
// a single separator
// ----------------------------------------------------
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
return trim($title, $separator);
......@@ -144,17 +124,13 @@ class URL {
{
$parameters = (isset($parameters[0])) ? $parameters[0] : array();
// ----------------------------------------------------
// Dynamically create a secure route URL.
// ----------------------------------------------------
if (strpos($method, 'to_secure_') === 0)
{
return static::to_route(substr($method, 10), $parameters, true);
}
// ----------------------------------------------------
// Dynamically create a route URL.
// ----------------------------------------------------
if (strpos($method, 'to_') === 0)
{
return static::to_route(substr($method, 3), $parameters);
......
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