Browse Source

Merge pull request #11262 from cakephp/text-slug-failing-test

Add failing test for Text::slug()
Mark Story 8 years ago
parent
commit
746dab64d2
2 changed files with 10 additions and 2 deletions
  1. 1 1
      src/Utility/Text.php
  2. 9 1
      tests/TestCase/Utility/TextTest.php

+ 1 - 1
src/Utility/Text.php

@@ -1108,7 +1108,7 @@ class Text
 
         $regex = '^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}';
         if ($options['preserve']) {
-            $regex .= '(' . preg_quote($options['preserve'], '/') . ')';
+            $regex .= '|' . preg_quote($options['preserve'], '/');
         }
         $quotedReplacement = preg_quote($options['replacement'], '/');
         $map = [

+ 9 - 1
tests/TestCase/Utility/TextTest.php

@@ -1804,7 +1804,15 @@ HTML;
             [
                 'clean!_me.tar.gz', ['preserve' => '.'],
                 'clean-me.tar.gz'
-            ]
+            ],
+            [
+                'cl#ean(me', [],
+                'cl-ean-me'
+            ],
+            [
+                'cl#ean(me.jpg', ['preserve' => '.'],
+                'cl-ean-me.jpg'
+            ],
         ];
     }