Make sure to return / and not empty string for stuff on domain root

This commit is contained in:
Alexandre Aubin 2020-04-23 17:02:58 +02:00
parent 428f0a61fc
commit 1ba08be8fb

View file

@ -455,6 +455,8 @@ def app_map(app=None, raw=False, user=None):
perm_domain, perm_path = perm_url.split("/", 1)
perm_path = "/" + perm_path.rstrip("/")
perm_path = perm_path if perm_path != "" else "/"
return perm_domain, perm_path
this_app_perms = {p: i for p, i in permissions.items() if p.startswith(app_id + ".") and i["url"]}
@ -490,7 +492,6 @@ def app_map(app=None, raw=False, user=None):
continue
perm_domain, perm_path = _sanitized_absolute_url(perm_info["url"])
if perm_name.endswith(".main"):
perm_label = label
else:
@ -1362,11 +1363,12 @@ def app_makedefault(operation_logger, app, domain=None):
elif domain not in domain_list()['domains']:
raise YunohostError('domain_unknown')
operation_logger.start()
if '/' in app_map(raw=True)[domain]:
raise YunohostError('app_make_default_location_already_used', app=app, domain=app_domain,
other_app=app_map(raw=True)[domain]["/"]["id"])
operation_logger.start()
# TODO / FIXME : current trick is to add this to conf.json.persisten
# This is really not robust and should be improved
# e.g. have a flag in /etc/yunohost/apps/$app/ to say that this is the
@ -1636,6 +1638,8 @@ def app_ssowatconf():
perm_domain, perm_path = perm_url.split("/", 1)
perm_path = "/" + perm_path.rstrip("/")
perm_path = perm_path if perm_path != "" else "/"
return perm_domain + perm_path
# Skipped