Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Left domain unchanged in obfuscate email func

IKarbowiaka60c71e5df08
diff --git a/saleor/core/anonymize.py b/saleor/core/anonymize.py
index b2cb547941..bf098c26f6 100644
--- a/saleor/core/anonymize.py
+++ b/saleor/core/anonymize.py
@@ -1,11 +1,9 @@
def obfuscate_email(value):
string_rep = str(value)
- if string_rep.endswith("@example.com"):
- return string_rep
if "@" not in str(string_rep):
return obfuscate_string(string_rep)
- username = str(string_rep).split("@")[0]
- return "%[email protected]" % str(username)[:1]
+ local_part, domain = str(string_rep).split("@")
+ return "{}...@{}".format(local_part[:1], domain)
def obfuscate_string(value, phone=False):
diff --git a/saleor/core/tests/test_anonymize.py b/saleor/core/tests/test_anonymize.py
index 9a5acc8456..d413a20513 100644
--- a/saleor/core/tests/test_anonymize.py
+++ b/saleor/core/tests/test_anonymize.py
@@ -9,7 +9,7 @@ def test_obfuscate_email():
result = obfuscate_email(email)
# then
- assert result == "[email protected]"
+ assert result == "[email protected]"
def test_obfuscate_email_example_email():
@@ -20,7 +20,7 @@ def test_obfuscate_email_example_email():
result = obfuscate_email(email)
# then
- assert result == "[email protected]"
+ assert result == "[email protected]"
def test_obfuscate_email_no_at_in_email():