Skip to content

Commit

Permalink
Make extensions handled in Routing\Route\Route
Browse files Browse the repository at this point in the history
They should be part of normal route generation with
other parts of the url.
  • Loading branch information
markstory committed Jul 4, 2012
1 parent 00f08f1 commit 1fa9da2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/Cake/Routing/Route/Route.php
Expand Up @@ -376,6 +376,13 @@ public function match($url, $context = array()) {
}
unset($url['_host'], $url['_scheme'], $url['_port'], $url['_base']);

// Move extension into the hostOptions so its not part of
// reverse matches.
if (isset($url['_ext'])) {
$hostOptions['_ext'] = $url['_ext'];
unset($url['_ext']);
}

if (isset($defaults['prefix'])) {
$url['prefix'] = $defaults['prefix'];
}
Expand Down Expand Up @@ -503,6 +510,9 @@ protected function _writeUrl($params, $pass = array(), $query = array()) {
$out
);
}
if (!empty($params['_ext'])) {
$out .= '.' . $params['_ext'];
}
if (!empty($query)) {
$out = rtrim($out, '/');
$out .= '?' . http_build_query($query);
Expand Down
9 changes: 6 additions & 3 deletions lib/Cake/Routing/Router.php
Expand Up @@ -635,7 +635,7 @@ public static function url($url = null, $options = false) {
$here = null;
}

$extension = $output = $frag = null;
$output = $frag = null;

if (empty($url)) {
$output = isset($here) ? $here : '/';
Expand All @@ -659,7 +659,7 @@ public static function url($url = null, $options = false) {
unset($url['#']);
}
if (isset($url['ext'])) {
$extension = '.' . $url['ext'];
$url['_ext'] = $url['ext'];
unset($url['ext']);
}
if (isset($url['ssl'])) {
Expand Down Expand Up @@ -693,6 +693,9 @@ public static function url($url = null, $options = false) {
'plugin' => $params['plugin']
);
$output = self::$_routes->match($url, $params);
// } elseif (is_string($url) && $url[0] !== '/') {
// named route.

} else {
// String urls.
if (
Expand Down Expand Up @@ -728,7 +731,7 @@ public static function url($url = null, $options = false) {
$output = rtrim($output, '/');
}
}
return $output . $extension . $frag;
return $output . $frag;
}

/**
Expand Down

0 comments on commit 1fa9da2

Please sign in to comment.