From 94a17d40da84b02ac0cd890a2f54e9656674ccb9 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Mon, 26 Nov 2012 16:43:47 +0100 Subject: [PATCH] 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 --- lib/Cake/Routing/Router.php | 2 +- lib/Cake/Test/Case/Routing/RouterTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 23b7f2d0e8c..ae76a5344ee 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -851,7 +851,7 @@ public static function url($url = null, $full = false) { $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 6d0c1912088..177f4008d76 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2540,6 +2540,12 @@ public function testUrlProtocol() { $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)); } /**