2021-06-23 21:31:50 +00:00
|
|
|
__filename__ = "domainhandler.py"
|
|
|
|
__author__ = "Bob Mottram"
|
|
|
|
__license__ = "AGPL3+"
|
|
|
|
__version__ = "1.2.0"
|
|
|
|
__maintainer__ = "Bob Mottram"
|
|
|
|
__email__ = "bob@freedombone.net"
|
|
|
|
__status__ = "Production"
|
|
|
|
__module_group__ = "Core"
|
|
|
|
|
|
|
|
|
|
|
|
def removeDomainPort(domain: str) -> str:
|
|
|
|
"""If the domain has a port appended then remove it
|
|
|
|
eg. mydomain.com:80 becomes mydomain.com
|
|
|
|
"""
|
|
|
|
if ':' in domain:
|
|
|
|
domain = domain.split(':')[0]
|
|
|
|
return domain
|
2021-06-23 21:44:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
def getPortFromDomain(domain: str) -> int:
|
|
|
|
"""If the domain has a port number appended then return it
|
|
|
|
"""
|
|
|
|
if ':' in domain:
|
|
|
|
portStr = domain.split(':')[1]
|
|
|
|
if portStr.isdigit():
|
|
|
|
return int(portStr)
|
|
|
|
return None
|