Skip to content

Commit

Permalink
fix(common): Correctly normalize strings with single quotes
Browse files Browse the repository at this point in the history
Closes #679
  • Loading branch information
michaelbromley committed Feb 4, 2021
1 parent 8a1ff82 commit 00e0ad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/common/src/normalize-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 1 addition & 1 deletion packages/common/src/normalize-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 00e0ad9

Please sign in to comment.