Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2nd param init value for Router::stripPlugin(), improving router's co…

…verage by adding tests for stripPlugin()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8245 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit d6a12ce5f1d7debb29985897028db51615857f05 1 parent ecd0015
Tim Koschuetzki tim-kos authored
Showing with 16 additions and 2 deletions.
  1. +1 −2  cake/libs/router.php
  2. +15 −0 cake/tests/cases/libs/router.test.php
3  cake/libs/router.php
View
@@ -1245,7 +1245,7 @@ function currentRoute() {
* @access public
* @static
*/
- function stripPlugin($base, $plugin) {
+ function stripPlugin($base, $plugin = null) {
if ($plugin != null) {
$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
$base = str_replace('//', '', $base);
@@ -1258,7 +1258,6 @@ function stripPlugin($base, $plugin) {
}
return $base;
}
-
/**
* Strip escape characters from parameter values.
*
15 cake/tests/cases/libs/router.test.php
View
@@ -1655,5 +1655,20 @@ function testRegexRouteMatching() {
$expected = '/test/test_another_action/locale:badness';
$this->assertEqual($result, $expected);
}
+/**
+ * testStripPlugin
+ *
+ * @return void
+ * @access public
+ */
+ function testStripPlugin() {
+ $pluginName = 'forums';
+ $url = 'example.com/' . $pluginName . '/';
+ $expected = 'example.com';
+
+ $this->assertEqual(Router::stripPlugin($url, $pluginName), $expected);
+ $this->assertEqual(Router::stripPlugin($url), $url);
+ $this->assertEqual(Router::stripPlugin($url, null), $url);
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.