Skip to content
Permalink
Browse files

Changed the regex to follow the RFC 3986, working to protocols like "…

…svn+ssh://" and "ed2k://"
  • Loading branch information...
jrbasso committed Nov 3, 2010
1 parent b752766 commit adb2d90b9a812cfb33016080935f13f5c2a26896
Showing with 17 additions and 1 deletion.
  1. +1 −1 cake/libs/router.php
  2. +16 −0 cake/tests/cases/libs/router.test.php
@@ -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);
@@ -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.
You can’t perform that action at this time.