Skip to content

Commit

Permalink
Changes to normalize string
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Jan 12, 2025
1 parent 1cdb32f commit 22a12bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/model/contracts/shared/giLodash.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ export function randomHexString (length: number): string {

export function normalizeString (str: string): string {
return str
// [1]. Normalize strings by replacing both apostrophes and single quotes with a standard character (reference issue: https://github.com/okTurtles/group-income/issues/2479)
.replace(/[']/g, "'")
// [1]. Normalize strings by replacing intial and final punctuation marks,
// which typically are used in smart quote substitution, with a standad
// character
// (reference issue: https://github.com/okTurtles/group-income/issues/2479)
.replace(/[\p{Pf}\p{Pi}]/gu, "'")
// [2]. Normalize the string based on 'Canonical equivalence'. eg) 'Amélie' !== 'Amélie' even when they are visually identical because their unicode sequences are different.
// (reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize#canonical_equivalence_normalization)
.normalize('NFC')
Expand Down

0 comments on commit 22a12bf

Please sign in to comment.