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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 8x 8x 8x 8x 8x 8x 8x 4x 4x | import md5 from 'tiny-hashes/md5' const PLUS_AND_DOT = /\.|\+.*$/g /** * Normalize email by lowering case and extracting + and . symbols for gmail * @param {string} email * @return {string} Normalized email. If not valid, returns and empty string */ export function normalizeEmail(email) { Iif (typeof email !== 'string') return '' email = email.toLowerCase() const emailParts = email.split(/@/) Iif (emailParts.length !== 2) return '' let [username, domain] = emailParts username = username.replace(PLUS_AND_DOT, '') return `${username}@${domain}` } export function hashEmail(email) { const normalizedEmail = normalizeEmail(email) return normalizedEmail ? md5(normalizedEmail) : '' } |