File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ const builtinOverridableReplacements = require('./overridable-replacements');
6
6
7
7
const decamelize = string => {
8
8
return string
9
+ // Separate capitalized words.
10
+ . replace ( / ( [ A - Z ] { 2 , } ) ( [ a - z \d ] + ) / g, '$1 $2' )
11
+ . replace ( / ( [ a - z \d ] + ) ( [ A - Z ] { 2 , } ) / g, '$1 $2' )
12
+
9
13
. replace ( / ( [ a - z \d ] ) ( [ A - Z ] ) / g, '$1 $2' )
10
14
. replace ( / ( [ A - Z ] + ) ( [ A - Z ] [ a - z \d ] + ) / g, '$1 $2' ) ;
11
15
} ;
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ test('main', t => {
21
21
t . is ( slugify ( 'foo🦄' ) , 'foo-unicorn' ) ;
22
22
t . is ( slugify ( '🦄🦄🦄' ) , 'unicorn-unicorn-unicorn' ) ;
23
23
t . is ( slugify ( 'foo&bar' ) , 'foo-and-bar' ) ;
24
+ t . is ( slugify ( 'foo360BAR' ) , 'foo360-bar' ) ;
25
+ t . is ( slugify ( 'FOO360' ) , 'foo-360' ) ;
26
+ t . is ( slugify ( 'FOObar' ) , 'foo-bar' ) ;
24
27
} ) ;
25
28
26
29
test ( 'custom separator' , t => {
You can’t perform that action at this time.
0 commit comments