mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-01 07:26:34 +02:00
Add in regex for subdomain checking
This commit is contained in:
parent
7fec0462f5
commit
816e678bf3
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
import logging
|
import logging
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import re
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from string import digits
|
from string import digits
|
||||||
from django_fsm import FSMField, transition, TransitionNotAllowed # type: ignore
|
from django_fsm import FSMField, transition, TransitionNotAllowed # type: ignore
|
||||||
|
@ -292,7 +293,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
def isSubdomain(self, nameserver: str):
|
def isSubdomain(self, nameserver: str):
|
||||||
"""Returns boolean if the domain name is found in the argument passed"""
|
"""Returns boolean if the domain name is found in the argument passed"""
|
||||||
return self.name in nameserver
|
subdomain_pattern = r"([\w-]+\.)*"
|
||||||
|
full_pattern = subdomain_pattern + self.name
|
||||||
|
regex = re.compile(full_pattern)
|
||||||
|
return bool(regex.match(nameserver))
|
||||||
|
|
||||||
def checkHostIPCombo(self, nameserver: str, ip: list[str]):
|
def checkHostIPCombo(self, nameserver: str, ip: list[str]):
|
||||||
"""Checks the parameters past for a valid combination
|
"""Checks the parameters past for a valid combination
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue