@@ -2,9 +2,9 @@ function createSlug(title) {
22 let slug = title . toLowerCase ( ) . trim ( ) ;
33
44 const sets = [
5- { to : 'nodejs' , from : / n o d e .j s / } , // Replace node.js
6- { to : '-and-' , from : / & / } , // Replace &
7- { to : '-' , from : / [ / _ , : ; \\ . ] / g } // Replace /_,:;\. and whitespace
5+ { to : 'nodejs' , from : / n o d e .j s / } , // Replace node.js
6+ { to : '-and-' , from : / & / } , // Replace &
7+ { to : '-' , from : / [ / _ , : ; \\ . ] / g } , // Replace /_,:;\. and whitespace
88 ] ;
99
1010 sets . forEach ( set => {
@@ -13,9 +13,9 @@ function createSlug(title) {
1313
1414 return slug
1515 . replace ( / [ ^ \w \- ] + / g, '' ) // Remove any non word characters
16- . replace ( / - - + / g, '-' ) // Replace multiple hyphens with single
17- . replace ( / ^ - / , '' ) // Remove any leading hyphen
18- . replace ( / - $ / , '' ) ; // Remove any trailing hyphen
16+ . replace ( / - - + / g, '-' ) // Replace multiple hyphens with single
17+ . replace ( / ^ - / , '' ) // Remove any leading hyphen
18+ . replace ( / - $ / , '' ) ; // Remove any trailing hyphen
1919}
2020
2121module . exports = createSlug ;
0 commit comments