Merge pull request #1683 from cisagov/za/1305-handle-www

(On getgov-backup) Ticket #1305: Handle www. in availablity check
This commit is contained in:
zandercymatics 2024-01-26 12:15:50 -07:00 committed by GitHub
commit ece81baac8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -57,6 +57,9 @@ class DomainHelper:
# If blank ok is true, just return the domain
return domain
if domain.startswith("www."):
domain = domain[4:]
if domain.endswith(".gov"):
domain = domain[:-4]

View file

@ -64,6 +64,12 @@ class TestFormValidation(MockEppLib):
form = DotGovDomainForm(data={"requested_domain": "top-level-agency"})
self.assertEqual(len(form.errors), 0)
def test_requested_domain_starting_www(self):
"""Test a valid domain name with .www at the beginning."""
form = DotGovDomainForm(data={"requested_domain": "www.top-level-agency"})
self.assertEqual(len(form.errors), 0)
self.assertEqual(form.cleaned_data["requested_domain"], "top-level-agency")
def test_requested_domain_ending_dotgov(self):
"""Just a valid domain name with .gov at the end."""
form = DotGovDomainForm(data={"requested_domain": "top-level-agency.gov"})