-
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.
Merge pull request #1559 from digitalfabrik/1381-comparison-applicant…
…-contact 1381: Make name comparison more robust
- Loading branch information
Showing
7 changed files
with
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module 'normalize-strings' { | ||
export default function normalize(str: string, customCharmap?: Record<string, string>): string | ||
} |
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 |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
"types": ["node", "jest"] | ||
}, | ||
"include": [ | ||
"@types", | ||
"src", | ||
"scripts", | ||
"jest.config.ts", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.