You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
398 B

  1. # frozen_string_literal: true
  2. module EmailHelper
  3. def self.included(base)
  4. base.extend(self)
  5. end
  6. def email_to_canonical_email(str)
  7. username, domain = str.downcase.split('@', 2)
  8. username, = username.gsub('.', '').split('+', 2)
  9. "#{username}@#{domain}"
  10. end
  11. def email_to_canonical_email_hash(str)
  12. Digest::SHA2.new(256).hexdigest(email_to_canonical_email(str))
  13. end
  14. end