Browse Source

Merge branch 'router-stars' from Hikkijp

Refs #3582, #3581
mark_story 12 years ago
parent
commit
55672b6df3

+ 4 - 1
lib/Cake/Routing/Route/CakeRoute.php

@@ -536,7 +536,10 @@ class CakeRoute {
 			$out = str_replace($search, $replace, $out);
 		}
 
-		if (strpos($this->template, '*')) {
+		if (strpos($this->template, '**') !== false) {
+			$out = str_replace('**', $params['pass'], $out);
+			$out = str_replace('%2F', '/', $out);
+		} elseif (strpos($this->template, '*') !== false) {
 			$out = str_replace('*', $params['pass'], $out);
 		}
 		$out = str_replace('//', '/', $out);

+ 17 - 0
lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php

@@ -874,6 +874,23 @@ class CakeRouteTest extends CakeTestCase {
 	}
 
 /**
+ * Test match() with trailing ** style routes.
+ *
+ * @return void
+ */
+	public function testMatchTrailing() {
+		$route = new CakeRoute('/pages/**', array('controller' => 'pages', 'action' => 'display'));
+		$id = 'test/ spaces/漢字/la†în';
+		$result = $route->match(array(
+			'controller' => 'pages',
+			'action' => 'display',
+			$id
+		));
+		$expected = '/pages/test/%20spaces/%E6%BC%A2%E5%AD%97/la%E2%80%A0%C3%AEn';
+		$this->assertEquals($expected, $result);
+	}
+
+/**
  * test restructuring args with pass key
  *
  * @return void