Permalink
Browse files

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

  • Loading branch information...
1 parent 739982a commit 94a17d40da84b02ac0cd890a2f54e9656674ccb9 @Schlaefer Schlaefer committed Nov 26, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/Cake/Routing/Router.php
  2. +6 −0 lib/Cake/Test/Case/Routing/RouterTest.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) === '/') {
@@ -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));
}
/**

0 comments on commit 94a17d4

Please sign in to comment.