Skip to content

Commit

Permalink
Updated checkStringForPII function to handle edge case for sensitive …
Browse files Browse the repository at this point in the history
…information that ends in punctuation.
  • Loading branch information
Matthew Guest - Work authored and Matthew Guest - Work committed Dec 19, 2024
1 parent 36d3996 commit c5b6e59
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions VAMobile/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ export function checkStringForPII(body: string): { found: boolean; newText: stri
.filter((value) => value !== '')
const bodySplit = body.split(/\s/).filter((value) => value !== '')
_.forEach(bodySplit, (text) => {
const trailingPunctuationMatch = text.match(/[.,!?;:]+$/)
let trailingPunctuation = ''
if (trailingPunctuationMatch) {
trailingPunctuation = trailingPunctuationMatch[0]
text = text.slice(0, -trailingPunctuation.length)
}
phoneMatch = PHONE_REGEX_EXP.exec(text)
ssnMatch = SSN_REGEX_EXP.exec(text)
emailMatch = EMAIL_REGEX_EXP.exec(text)
Expand All @@ -460,6 +466,7 @@ export function checkStringForPII(body: string): { found: boolean; newText: stri
found = true
text = '[email protected]'
}
text = text + trailingPunctuation
newText = newText.concat(text)
newText = newText.concat(whiteSpace.pop() || '')
})
Expand Down

0 comments on commit c5b6e59

Please sign in to comment.