diff --git a/packages/common/src/normalize-string.spec.ts b/packages/common/src/normalize-string.spec.ts index b0324c8ac1..149a4453e0 100644 --- a/packages/common/src/normalize-string.spec.ts +++ b/packages/common/src/normalize-string.spec.ts @@ -37,4 +37,13 @@ describe('normalizeString()', () => { expect(normalizeString('Capture d’écran')).toBe('capture decran'); expect(normalizeString('Capture d‘écran')).toBe('capture decran'); }); + + it('replaces eszett with double-s digraph', () => { + expect(normalizeString('KONGREẞ im Straßennamen')).toBe('kongress im strassennamen'); + }); + + // works for German language, might not work for e.g. Finnish language + it('replaces combining diaeresis with e', () => { + expect(normalizeString('Ja quäkt Schwyz Pöbel vor Gmünd')).toBe('ja quaekt schwyz poebel vor gmuend'); + }); }); diff --git a/packages/common/src/normalize-string.ts b/packages/common/src/normalize-string.ts index b3fc74c814..2e895afb7b 100644 --- a/packages/common/src/normalize-string.ts +++ b/packages/common/src/normalize-string.ts @@ -6,6 +6,9 @@ export function normalizeString(input: string, spaceReplacer = ' '): string { return (input || '') .normalize('NFD') + .replace(/[\u00df]/g, 'ss') + .replace(/[\u1e9e]/g, 'SS') + .replace(/[\u0308]/g, 'e') .replace(/[\u0300-\u036f]/g, '') .toLowerCase() .replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬'=‘’©®™]/g, '') diff --git a/packages/core/e2e/collection.e2e-spec.ts b/packages/core/e2e/collection.e2e-spec.ts index 8585af9fa4..e5be4ae5bc 100644 --- a/packages/core/e2e/collection.e2e-spec.ts +++ b/packages/core/e2e/collection.e2e-spec.ts @@ -253,7 +253,7 @@ describe('Collection resolver', () => { 'accessories', ); expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe( - 'zubehor', + 'zubehoer', ); }); @@ -285,7 +285,7 @@ describe('Collection resolver', () => { 'accessories-2', ); expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe( - 'zubehor-2', + 'zubehoer-2', ); }); @@ -317,7 +317,7 @@ describe('Collection resolver', () => { 'accessories', ); expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe( - 'zubehor', + 'zubehoer', ); });