fix ticket 3400: url string with # in it is not routed

See: http://cakephp.lighthouseapp.com/projects/42648/tickets/3400-url-string-with-in-it-is-not-routed
This commit is contained in:
Schlaefer 2012-11-26 16:43:47 +01:00
parent 739982addb
commit 94a17d40da
2 changed files with 7 additions and 1 deletions

View file

@ -851,7 +851,7 @@ class Router {
$output = self::_handleNoRoute($url);
}
} else {
if (preg_match('/:\/\/|^(javascript|mailto|tel|sms):|\#/i', $url)) {
if (preg_match('/:\/\/|^(javascript|mailto|tel|sms):|^\#/i', $url)) {
return $url;
}
if (substr($url, 0, 1) === '/') {

View file

@ -2540,6 +2540,12 @@ class RouterTest extends CakeTestCase {
$url = 'sms:012345-678';
$this->assertEquals($url, Router::url($url));
$url = '#here';
$this->assertEquals($url, Router::url($url));
$url = 'posts/index#here';
$expected = FULL_BASE_URL . '/posts/index#here';
$this->assertEquals($expected, Router::url($url, true));
}
/**