mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
domain_info: add 'topest_parent' info + fix small bug with return_self option for _get_parent_domain_of
This commit is contained in:
parent
435084c20b
commit
b30962a44f
1 changed files with 9 additions and 6 deletions
|
@ -167,6 +167,7 @@ def domain_info(domain):
|
|||
"registrar": registrar,
|
||||
"apps": apps,
|
||||
"main": _get_maindomain() == domain,
|
||||
"topest_parent": _get_parent_domain_of(domain, return_self=True, topest=True),
|
||||
# TODO : add parent / child domains ?
|
||||
}
|
||||
|
||||
|
@ -188,15 +189,17 @@ def _list_subdomains_of(parent_domain):
|
|||
return out
|
||||
|
||||
|
||||
def _get_parent_domain_of(domain, return_self=True):
|
||||
def _get_parent_domain_of(domain, return_self=True, topest=False):
|
||||
|
||||
_assert_domain_exists(domain)
|
||||
|
||||
domains = _get_domains()
|
||||
while "." in domain:
|
||||
domain = domain.split(".", 1)[1]
|
||||
if domain in domains:
|
||||
return domain
|
||||
domains = _get_domains(exclude_subdomains=topest)
|
||||
|
||||
domain_ = domain
|
||||
while "." in domain_:
|
||||
domain_ = domain_.split(".", 1)[1]
|
||||
if domain_ in domains:
|
||||
return domain_
|
||||
|
||||
return domain if return_self else None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue