Skip to content

Commit cc1de6c

Browse files
committed
Fix Router::url() in 3.0
1 parent a8d5052 commit cc1de6c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/Cake/Routing/Router.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,7 @@ public static function url($url = null, $options = array()) {
800800
if ($plainString) {
801801
return $url;
802802
}
803-
$output = $url;
804-
if ($hasLeadingSlash && strlen($output) > 1) {
805-
$output = substr($output, 1);
806-
}
807-
$output = $base . $output;
803+
$output = $base . $url;
808804
}
809805
$protocol = preg_match('#^[a-z][a-z0-9+\-.]*\://#i', $output);
810806
if ($protocol === 0) {

lib/Cake/Test/TestCase/Routing/RouterTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,12 @@ public function testUrlGenerationWithBasePath() {
411411
$result = Router::url('/');
412412
$this->assertEquals('/magazine/', $result);
413413

414+
$result = Router::url('/articles/');
415+
$this->assertEquals('/magazine/articles/', $result);
416+
417+
$result = Router::url('/articles/view');
418+
$this->assertEquals('/magazine/articles/view', $result);
419+
414420
$result = Router::url(['controller' => 'articles', 'action' => 'view', 1]);
415421
$this->assertEquals('/magazine/articles/view/1', $result);
416422
}

0 commit comments

Comments
 (0)