|
|
@@ -4,6 +4,8 @@
|
|
|
* Based on https://stackoverflow.com/a/37511463/772859
|
|
|
*/
|
|
|
export function normalizeString(input: string, spaceReplacer = ' '): string {
|
|
|
+ const multipleSequentialReplacerRegex = new RegExp(`([${spaceReplacer}]){2,}`, 'g');
|
|
|
+
|
|
|
return (input || '')
|
|
|
.normalize('NFD')
|
|
|
.replace(/[\u00df]/g, 'ss')
|
|
|
@@ -12,5 +14,6 @@ export function normalizeString(input: string, spaceReplacer = ' '): string {
|
|
|
.replace(/[\u0300-\u036f]/g, '')
|
|
|
.toLowerCase()
|
|
|
.replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬'=‘’©®™]/g, '')
|
|
|
- .replace(/\s+/g, spaceReplacer);
|
|
|
+ .replace(/\s+/g, spaceReplacer)
|
|
|
+ .replace(multipleSequentialReplacerRegex, spaceReplacer);
|
|
|
}
|