Merge commit 'a485f97d21c3fb7da927e8fd239b301a590ee9b8' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2025-08-07 18:16:54 +02:00
commit e68de292b4
46 files changed
+945 -100

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
# frozen_string_literal: true
module CanonicalEmail
extend ActiveSupport::Concern
included do
normalizes :email, with: ->(value) { canonicalize_email(value) }
end
class_methods do
def canonicalize_email(email)
email
.downcase
.split('@', 2)
.then { |local, domain| [canonical_username(local), domain] }
.join('@')
end
def canonical_username(username)
username
.to_s
.delete('.')
.split('+', 2)
.first
end
end
end