EmailHelper.coffee 428 B

12345678910111213
  1. 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,}))$/
  2. module.exports = EmailHelper =
  3. parseEmail: (email) ->
  4. return null unless email?
  5. return null if email.length > 254
  6. email = email.trim().toLowerCase()
  7. matched = email.match EMAIL_REGEXP
  8. return null unless matched? && matched[0]?
  9. matched[0]