All files / src/features/properties address-match.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12        4x 20x       10x    
// The street address typed to confirm deleting a flat (openspec: properties,
// "Confirming the deletion of a flat"). It guards against a slip of the
// finger, not an attacker, so it is checked in the browser only.
 
const normalise = (text: string) =>
  text.trim().replace(/\s+/gu, ' ').toLocaleLowerCase('fi-FI')
 
/** Whether the typed text is the street address, ignoring case and extra spaces. */
export function addressMatches(typed: string, streetAddress: string): boolean {
  return normalise(typed) === normalise(streetAddress)
}