File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -104,17 +104,24 @@ export function useHelper() {
104104 const b = 'aaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnooooooooprrssssttuuuuuuuuwxyyzzz------' ;
105105 const p = new RegExp ( a . split ( '' ) . join ( '|' ) , 'g' ) ;
106106
107- return input
107+ const result = input
108108 . toString ( )
109109 . toLowerCase ( )
110110 . replace ( / [ ä ö ü ß ] / gi, ( matched ) => specialChars [ matched . toLowerCase ( ) ] ) // German special chars
111111 . replace ( / \s + / g, '-' ) // Replace spaces with -
112112 . replace ( p , ( c ) => b . charAt ( a . indexOf ( c ) ) ) // Replace special characters
113113 . replace ( / & / g, '-' ) // Replace & with -
114- . replace ( new RegExp ( allowDots ? `[^\w\-.]+` : `[^\w-]+` , 'g' ) , '' ) // Allow dots if requested
115114 . replace ( / \- \- + / g, '-' ) // Collapse multiple -
116115 . replace ( / ^ - + / , '' ) // Trim leading -
117116 . replace ( / - + $ / , '' ) ; // Trim trailing -
117+
118+ if ( allowDots ) {
119+ result = result . replace ( / [ ^ \w \- . ] + / g, '' ) // Removes all non-word characters except for dots
120+ } else {
121+ result = result . replace ( / [ ^ \w \- ] + / g, '' ) ; // Remove all non-word characters
122+ }
123+
124+ return result ;
118125 }
119126
120127 function hashCode ( input : any ) {
You can’t perform that action at this time.
0 commit comments