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')
4
4
5
5
module . exports = normalize
6
6
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 ) )
17
9
. toLowerCase ( )
18
- . replace ( apostrophe , "'" )
19
-
20
- if ( allowApostrophes && allowDashes ) {
21
- return result
22
- }
10
+ . replace ( / ’ / g, "'" )
23
11
24
- if ( allowApostrophes ) {
25
- return result . replace ( dash , '' )
12
+ if ( ! options || ! options . allowDashes ) {
13
+ value = value . replace ( / - / g , '' )
26
14
}
27
15
28
- if ( allowDashes ) {
29
- return result . replace ( singleQuote , '' )
16
+ if ( ! options || ! options . allowApostrophes ) {
17
+ value = value . replace ( / ' / g , '' )
30
18
}
31
19
32
- return result . replace ( all , '' )
20
+ return value
33
21
}
You can’t perform that action at this time.
0 commit comments