diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 23b7f2d0e..ae76a5344 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -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) === '/') { diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 6d0c19120..177f4008d 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -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)); } /**