From 00e0ad9c0d48673454166267b49e483d955c14fc Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Thu, 4 Feb 2021 12:55:58 +0100 Subject: [PATCH] fix(common): Correctly normalize strings with single quotes Closes #679 --- packages/common/src/normalize-string.spec.ts | 6 ++++++ packages/common/src/normalize-string.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/common/src/normalize-string.spec.ts b/packages/common/src/normalize-string.spec.ts index c39643fb5e..7f89a6b455 100644 --- a/packages/common/src/normalize-string.spec.ts +++ b/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'); + }); }); diff --git a/packages/common/src/normalize-string.ts b/packages/common/src/normalize-string.ts index 618f1ff307..48aa45c676 100644 --- a/packages/common/src/normalize-string.ts +++ b/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); }