-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1381: Make name comparison more robust
- Loading branch information
1 parent
efccde7
commit 19b5264
Showing
5 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import normalizeString, { normalizeName } from '../normalizeString' | ||
|
||
describe('normalizeString', () => { | ||
it('should normalize search string', () => { | ||
expect(normalizeString('Donauwörth')).toBe('donauworth') | ||
expect(normalizeString('äöUEJJ')).toBe('aouejj') | ||
}) | ||
|
||
it('should trim whitespaces', () => { | ||
expect(normalizeString(' test ')).toBe('test') | ||
}) | ||
}) | ||
|
||
describe('normalizeName', () => { | ||
it('should normalize search string', () => { | ||
expect(normalizeName('Dr. Hans-Peter Müller Lüdenscheid ')).toBe('drhanspetermullerludenscheid') | ||
expect(normalizeName('Dr. Hans Peter Müller Lüdenscheid')).toBe('drhanspetermullerludenscheid') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import normalizeStrings from 'normalize-strings' | ||
|
||
const normalizeString = (str: string): string => normalizeStrings(str).toLowerCase().trim() | ||
export const normalizeName = (name: string) => normalizeString(name).replaceAll(/[^a-zA-Z0-9]/g, '') | ||
|
||
export default normalizeString |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.