mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Changed the regex to follow the RFC 3986, working to protocols like "svn+ssh://" and "ed2k://"
This commit is contained in:
parent
b752766d6c
commit
adb2d90b9a
2 changed files with 17 additions and 1 deletions
|
@ -831,7 +831,7 @@ class Router {
|
|||
$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 @@ class RouterTest extends CakeTestCase {
|
|||
$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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue