Get rid of the regex

Regexes are hard to read, and this one is probably quite slow because
the string formatting means it can never be precompiled.
This commit is contained in:
Chris Hill-Scott
2018-02-06 14:14:12 +00:00
parent be18448f2a
commit 9e8d69da7d

View File

@@ -466,9 +466,12 @@ class GovernmentDomain:
def fn(domain):
return (email_address_or_domain == domain) or re.search(
"[\.|@]({})$".format(domain.replace(".", "\.")),
email_address_or_domain
return (
email_address_or_domain == domain
) or (
email_address_or_domain.endswith("@{}".format(domain))
) or (
email_address_or_domain.endswith(".{}".format(domain))
)
return fn