2018-06-11 06:29:08 -04:00
|
|
|
EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\ ".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA -Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
2016-08-02 09:30:42 -04:00
|
|
|
|
2016-08-02 10:42:26 -04:00
|
|
|
module.exports = EmailHelper =
|
2016-08-02 09:30:42 -04:00
|
|
|
|
|
|
|
parseEmail: (email) ->
|
2018-06-11 06:29:08 -04:00
|
|
|
return null unless email?
|
2019-01-29 15:14:59 -05:00
|
|
|
return null if email.length > 254
|
2018-06-11 06:29:08 -04:00
|
|
|
email = email.trim().toLowerCase()
|
|
|
|
|
|
|
|
matched = email.match EMAIL_REGEXP
|
|
|
|
return null unless matched? && matched[0]?
|
|
|
|
|
|
|
|
matched[0]
|