overleaf/services/web/app/coffee/Features/Helpers/EmailHelper.coffee
Tim Alby 97c145433e use EmailHelper.parseEmail on registration
Also changed EmailHelper to use the regexp already used in
UserRegistrationHandler rather than the `mimelib` package as it is
deprecated.
2018-06-11 12:31:18 +02:00

12 lines
392 B
CoffeeScript

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,}))$/
module.exports = EmailHelper =
parseEmail: (email) ->
return null unless email?
email = email.trim().toLowerCase()
matched = email.match EMAIL_REGEXP
return null unless matched? && matched[0]?
matched[0]