Skip to content

Commit

Permalink
Remove nested conditionals.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 26, 2012
1 parent 9c0939b commit 7402eea
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions lib/Cake/View/Helper.php
Expand Up @@ -292,36 +292,37 @@ public function webroot($file) {
*/
public function assetUrl($path, $options = array()) {
if (is_array($path)) {
$path = $this->url($path, !empty($options['fullBase']));
} elseif (strpos($path, '://') === false) {
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
list($plugin, $path) = $this->_View->pluginSplit($path, false);
}
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
$path = $options['pathPrefix'] . $path;
}
if (
!empty($options['ext']) &&
strpos($path, '?') === false &&
substr($path, -strlen($options['ext'])) !== $options['ext']
) {
$path .= $options['ext'];
}
if (isset($plugin)) {
$path = Inflector::underscore($plugin) . '/' . $path;
}
$path = h($this->assetTimestamp($this->webroot($path)));
return $this->url($path, !empty($options['fullBase']));
}
if (strpos($path, '://') !== false) {
return $path;
}
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
list($plugin, $path) = $this->_View->pluginSplit($path, false);
}
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
$path = $options['pathPrefix'] . $path;
}
if (
!empty($options['ext']) &&
strpos($path, '?') === false &&
substr($path, -strlen($options['ext'])) !== $options['ext']
) {
$path .= $options['ext'];
}
if (isset($plugin)) {
$path = Inflector::underscore($plugin) . '/' . $path;
}
$path = h($this->assetTimestamp($this->webroot($path)));

if (!empty($options['fullBase'])) {
$base = $this->url('/', true);
$len = strlen($this->request->webroot);
if ($len) {
$base = substr($base, 0, -$len);
}
$path = $base . $path;
if (!empty($options['fullBase'])) {
$base = $this->url('/', true);
$len = strlen($this->request->webroot);
if ($len) {
$base = substr($base, 0, -$len);
}
$path = $base . $path;
}

return $path;
}

Expand Down

0 comments on commit 7402eea

Please sign in to comment.