mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 19:48:36 +02:00
excluding - and . from string length
This commit is contained in:
parent
0b22d5e63a
commit
194a115777
1 changed files with 9 additions and 2 deletions
|
@ -310,7 +310,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
- first character is alpha
|
- first character is alpha
|
||||||
- last character is not - or .
|
- last character is not - or .
|
||||||
- all characters alpha, 0-9, -, or .
|
- all characters alpha, 0-9, -, or .
|
||||||
- 2 character min, 24 character max
|
- 2 character min, 24 character max (not including dashes/periods)
|
||||||
"""
|
"""
|
||||||
# pattern to test for valid domain
|
# pattern to test for valid domain
|
||||||
# pattern = r'^[a-zA-Z][a-zA-Z0-9-.]{0,22}[a-zA-Z0-9]$'
|
# pattern = r'^[a-zA-Z][a-zA-Z0-9-.]{0,22}[a-zA-Z0-9]$'
|
||||||
|
@ -319,9 +319,16 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# attempt to match the pattern
|
# attempt to match the pattern
|
||||||
match = re.match(pattern, nameserver)
|
match = re.match(pattern, nameserver)
|
||||||
|
|
||||||
|
# length of nameserver, not including - or .
|
||||||
|
characters_to_exclude = "-."
|
||||||
|
filtered_nameserver = "".join(
|
||||||
|
char for char in nameserver if char not in characters_to_exclude
|
||||||
|
)
|
||||||
|
nameserverLength = len(filtered_nameserver)
|
||||||
|
|
||||||
# return true if nameserver matches, and length less than 25;
|
# return true if nameserver matches, and length less than 25;
|
||||||
# otherwise false
|
# otherwise false
|
||||||
return bool(match) and len(nameserver) < 25
|
return bool(match) and nameserverLength < 25
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def checkHostIPCombo(cls, name: str, nameserver: str, ip: list[str]):
|
def checkHostIPCombo(cls, name: str, nameserver: str, ip: list[str]):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue