Skip to content

Commit

Permalink
Minor optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 11, 2014
1 parent ae76e5e commit df28a0d
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/Routing/Router.php
Expand Up @@ -502,22 +502,6 @@ public static function url($url = null, $full = false) {
static::_loadRoutes();
}

$urlType = gettype($url);
$plainString = false;

if ($urlType === 'string') {
$plainString = (
strpos($url, 'javascript:') === 0 ||
strpos($url, 'mailto:') === 0 ||
strpos($url, 'tel:') === 0 ||
strpos($url, 'sms:') === 0 ||
strpos($url, '#') === 0 ||
strpos($url, '?') === 0 ||
strpos($url, '//') === 0 ||
strpos($url, '://') !== false
);
}

$params = array(
'plugin' => null,
'controller' => null,
Expand All @@ -542,7 +526,7 @@ public static function url($url = null, $full = false) {
$output = static::fullBaseUrl() . $base . $output;
}
return $output;
} elseif ($urlType === 'array') {
} elseif (is_array($url)) {
if (isset($url['_full']) && $url['_full'] === true) {
$full = true;
unset($url['_full']);
Expand Down Expand Up @@ -587,7 +571,17 @@ public static function url($url = null, $full = false) {
$url = static::_applyUrlFilters($url);
$output = static::$_collection->match($url, static::$_requestContext);
} else {
// String urls.
$plainString = (
strpos($url, 'javascript:') === 0 ||
strpos($url, 'mailto:') === 0 ||
strpos($url, 'tel:') === 0 ||
strpos($url, 'sms:') === 0 ||
strpos($url, '#') === 0 ||
strpos($url, '?') === 0 ||
strpos($url, '//') === 0 ||
strpos($url, '://') !== false
);

if ($plainString) {
return $url;
}
Expand Down

0 comments on commit df28a0d

Please sign in to comment.