2021-04-16 18:14:25 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module EmailHelper
|
|
|
|
def self.included(base)
|
|
|
|
base.extend(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
def email_to_canonical_email(str)
|
|
|
|
username, domain = str.downcase.split('@', 2)
|
2023-02-07 18:21:21 -08:00
|
|
|
username, = username.delete('.').split('+', 2)
|
2021-04-16 18:14:25 -07:00
|
|
|
|
|
|
|
"#{username}@#{domain}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def email_to_canonical_email_hash(str)
|
|
|
|
Digest::SHA2.new(256).hexdigest(email_to_canonical_email(str))
|
|
|
|
end
|
|
|
|
end
|