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 | 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x | const DOT_REG = /\./g;
/**
* 1. Lower-cases whole email.
* 2. Removes dots ".".
* 3. Remotes name part after "+".
* 4. Throws if cannot parse the email.
*
* For example, this email
*
* Michal.Loler+twitter@Gmail.com
*
* will be normalized to
*
* michalloler@gmail.com
*
*/
export const normalizeEmail = (email: string) => {
const [name, host] = email.split('@');
let [beforePlus] = name.split('+');
beforePlus = beforePlus.replace(DOT_REG, '');
const result = beforePlus.toLowerCase() + '@' + host.toLowerCase();
Number(result);
return result;
};
|