diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index b3ee55574..c2ebd046a 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -105,6 +105,12 @@ def get_hostname(): def home_page_url2scid(url): """Return the shortcut ID of the given home page url.""" + # url is None when the freedombox-apache-homepage configuration file does + # not exist. In this case, the default redirect in /plinth from the shipped + # configuration file is effective. + if url is None: + return 'plinth' + if url in ('/plinth/', '/plinth', 'plinth'): return 'plinth' diff --git a/plinth/modules/config/tests/test_config.py b/plinth/modules/config/tests/test_config.py index 265512e25..d03adc412 100644 --- a/plinth/modules/config/tests/test_config.py +++ b/plinth/modules/config/tests/test_config.py @@ -76,7 +76,7 @@ def test_domainname_field(): def test_homepage_mapping(): """Basic tests for homepage functions.""" func = home_page_url2scid - assert func(None) is None + assert func(None) == 'plinth' assert func('/unknown/url') is None assert func('/plinth/') == 'plinth' assert func('/plinth') == 'plinth'