Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor optimizations in Router

  • Loading branch information...
commit 2b353e90f83280abfb8a93f42e624bc1417af0be 1 parent 57997e7
@markstory markstory authored
Showing with 7 additions and 10 deletions.
  1. +7 −10 cake/libs/router.php
View
17 cake/libs/router.php
@@ -788,7 +788,7 @@ function url($url = null, $full = false) {
$prefixExists = (array_intersect_key($url, array_flip($self->__prefixes)));
foreach ($self->__prefixes as $prefix) {
- if (!isset($url[$prefix]) && !empty($params[$prefix]) && !$prefixExists) {
+ if (!empty($params[$prefix]) && !$prefixExists) {
$url[$prefix] = true;
} elseif (isset($url[$prefix]) && !$url[$prefix]) {
unset($url[$prefix]);
@@ -812,7 +812,6 @@ function url($url = null, $full = false) {
if ($match = $self->routes[$i]->match($url)) {
$output = trim($match, '/');
- $url = array();
break;
}
$url = $originalUrl;
@@ -1537,14 +1536,12 @@ function _writeUrl($params) {
$instance =& Router::getInstance();
$separator = $instance->named['separator'];
- if (!empty($params['named'])) {
- if (is_array($params['named'])) {
- $named = array();
- foreach ($params['named'] as $key => $value) {
- $named[] = $key . $separator . $value;
- }
- $params['pass'] = $params['pass'] . '/' . implode('/', $named);;
+ if (!empty($params['named']) && is_array($params['named'])) {
+ $named = array();
+ foreach ($params['named'] as $key => $value) {
+ $named[] = $key . $separator . $value;
}
+ $params['pass'] = $params['pass'] . '/' . implode('/', $named);
}
$out = $this->template;
@@ -1554,7 +1551,7 @@ function _writeUrl($params) {
if (isset($params[$key])) {
$string = $params[$key];
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
- $key = $key . '/';
+ $key .= '/';
}
$search[] = ':' . $key;
$replace[] = $string;
Please sign in to comment.
Something went wrong with that request. Please try again.