Skip to content

Commit

Permalink
fix ticket 3400: url string with # in it is not routed
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Nov 26, 2012
1 parent 739982a commit 94a17d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -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) === '/') {
Expand Down
6 changes: 6 additions & 0 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 94a17d4

Please sign in to comment.