Browse Source

fix(common): Correctly normalize strings with single quotes

Closes #679
Michael Bromley 5 years ago
parent
commit
d12f369b97

+ 6 - 0
packages/common/src/normalize-string.spec.ts

@@ -29,4 +29,10 @@ describe('normalizeString()', () => {
     it('allows a subset of non-alphanumeric characters to pass through', () => {
         expect(normalizeString('-_.')).toBe('-_.');
     });
+
+    // https://github.com/vendure-ecommerce/vendure/issues/679
+    it('replaces single quotation marks', () => {
+        expect(normalizeString('Capture d’écran')).toBe('capture decran');
+        expect(normalizeString('Capture d‘écran')).toBe('capture decran');
+    });
 });

+ 1 - 1
packages/common/src/normalize-string.ts

@@ -8,6 +8,6 @@ export function normalizeString(input: string, spaceReplacer = ' '): string {
         .normalize('NFD')
         .replace(/[\u0300-\u036f]/g, '')
         .toLowerCase()
-        .replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬'=]/g, '')
+        .replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬'=‘’]/g, '')
         .replace(/\s+/g, spaceReplacer);
 }