Coverage for app/venv/lib/python3.14/site-packages/weblate/utils/site.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5from django.conf import settings 

6 

7# List of default domain names on which warn user 

8DEFAULT_DOMAINS = ("", "*") 

9 

10 

11def get_site_domain(): 

12 """Return current site domain.""" 

13 return settings.SITE_DOMAIN 

14 

15 

16def get_site_url(url="") -> str: 

17 """Return root url of current site with domain.""" 

18 protocol = "https" if settings.ENABLE_HTTPS else "http" 

19 return f"{protocol}://{get_site_domain()}{url}" 

20 

21 

22def check_domain(domain): 

23 """Check whether site domain is correctly set.""" 

24 return ( 

25 domain not in DEFAULT_DOMAINS 

26 and not domain.startswith("http:") 

27 and not domain.startswith("https:") 

28 and not domain.endswith("/") 

29 )