Skip to content

Commit

Permalink
Changed the regex to follow the RFC 3986, working to protocols like "…
Browse files Browse the repository at this point in the history
…svn+ssh://" and "ed2k://"
  • Loading branch information
jrbasso committed Nov 3, 2010
1 parent b752766 commit adb2d90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/router.php
Expand Up @@ -831,7 +831,7 @@ public static function url($url = null, $full = false) {
$output .= Inflector::underscore($params['controller']) . '/' . $url;
}
}
$protocol = preg_match('#^[a-z]+\://#', $output);
$protocol = preg_match('#^[a-z][a-z0-9+-.]*\://#i', $output);
if ($protocol === 0) {
$output = str_replace('//', '/', $base . '/' . $output);

Expand Down
16 changes: 16 additions & 0 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -2248,4 +2248,20 @@ function testUrlFullUrlReturnFromRoute() {
$this->assertEquals($url, $result);
}

/**
* test protocol in url
*
* @return void
*/
public function testUrlProtocol() {
$url = 'http://example.com';
$this->assertEqual($url, Router::url($url));

$url = 'ed2k://example.com';
$this->assertEqual($url, Router::url($url));

$url = 'svn+ssh://example.com';
$this->assertEqual($url, Router::url($url));
}

}

0 comments on commit adb2d90

Please sign in to comment.