From dff8d5dc951fe261d830eb1ea1e465891e189235 Mon Sep 17 00:00:00 2001 From: Udit Manav Date: Thu, 17 Jul 2025 12:49:30 +0530 Subject: [PATCH 1/2] copilot PR test --- copilot_pr_test.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 copilot_pr_test.py diff --git a/copilot_pr_test.py b/copilot_pr_test.py new file mode 100644 index 0000000..746918e --- /dev/null +++ b/copilot_pr_test.py @@ -0,0 +1,32 @@ +# email_utils.py + +import re + +# NOTE: chose a shorter regex but lost some precision +_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}") + + +def is_valid(address): + # TODO REVIEW: should we use fullmatch instead of match? + return bool(_RE.match(address)) + + +def get_domain(addr): + # returns everything after the last "@" + return addr[addr.rfind("@") + 1 :] # BUG: returns whole string if "@" missing + + +def local_part(addr): + return addr.split("@")[0] # lacks error handling for malformed addr + + +def masked_email(e, show=2): + """ + Mask an email so only *show* chars of the local part remain visible, + e.g. jo******@example.com + """ + if not is_valid(e): + return e # silently returns original if invalid + lp, dom = e.split("@") + masked = lp[:show] + "*" * (len(lp) - show) + return masked + "@" + dom From 610dad9a182aa9be9fee1e224dc99b1c48ccfd00 Mon Sep 17 00:00:00 2001 From: Udit Manav Date: Thu, 17 Jul 2025 19:01:48 +0530 Subject: [PATCH 2/2] Update copilot_pr_test.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- copilot_pr_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copilot_pr_test.py b/copilot_pr_test.py index 746918e..9463ac7 100644 --- a/copilot_pr_test.py +++ b/copilot_pr_test.py @@ -29,4 +29,4 @@ def masked_email(e, show=2): return e # silently returns original if invalid lp, dom = e.split("@") masked = lp[:show] + "*" * (len(lp) - show) - return masked + "@" + dom + return f"{masked}@{dom}"