init
This commit is contained in:
0
app/services/__init__.py
Normal file
0
app/services/__init__.py
Normal file
21
app/services/email_normalizer.py
Normal file
21
app/services/email_normalizer.py
Normal file
@@ -0,0 +1,21 @@
|
||||
def normalize_email(email):
|
||||
"""
|
||||
对邮箱地址进行归一化处理。
|
||||
- 全部转为小写。
|
||||
- 对 Gmail/Googlemail: 移除 '.' 和 '+' 后面的所有内容。
|
||||
"""
|
||||
if not email or '@' not in email:
|
||||
return None
|
||||
|
||||
email = email.lower().strip()
|
||||
local_part, domain_part = email.split('@', 1)
|
||||
|
||||
# 针对 Gmail 和 Googlemail 的特殊处理
|
||||
if domain_part in ('gmail.com', 'googlemail.com'):
|
||||
# 移除 '+' 及其后面的部分
|
||||
local_part = local_part.split('+', 1)[0]
|
||||
# 移除 '.'
|
||||
local_part = local_part.replace('.', '')
|
||||
|
||||
return f"{local_part}@{domain_part}"
|
||||
|
||||
Reference in New Issue
Block a user