File tree Expand file tree Collapse file tree 1 file changed +8
-20
lines changed Expand file tree Collapse file tree 1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -4,30 +4,18 @@ var toString = require('nlcst-to-string')
44
55module . exports = normalize
66
7- var all = / [ - ' ] / g
8- var dash = / - / g
9- var apostrophe = / ’ / g
10- var singleQuote = / ' / g
11-
12- function normalize ( value , options ) {
13- var settings = options || { }
14- var allowApostrophes = settings . allowApostrophes
15- var allowDashes = settings . allowDashes
16- var result = ( typeof value === 'string' ? value : toString ( value ) )
7+ function normalize ( node , options ) {
8+ var value = ( typeof node === 'string' ? node : toString ( node ) )
179 . toLowerCase ( )
18- . replace ( apostrophe , "'" )
19-
20- if ( allowApostrophes && allowDashes ) {
21- return result
22- }
10+ . replace ( / ’ / g, "'" )
2311
24- if ( allowApostrophes ) {
25- return result . replace ( dash , '' )
12+ if ( ! options || ! options . allowDashes ) {
13+ value = value . replace ( / - / g , '' )
2614 }
2715
28- if ( allowDashes ) {
29- return result . replace ( singleQuote , '' )
16+ if ( ! options || ! options . allowApostrophes ) {
17+ value = value . replace ( / ' / g , '' )
3018 }
3119
32- return result . replace ( all , '' )
20+ return value
3321}
You can’t perform that action at this time.
0 commit comments