summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2019-11-04 22:34:49 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2019-11-05 08:12:04 (GMT)
commite1bc7bcf4a2d389a7d93982cc82f486fe548e247 (patch)
treec4995c77316005344b1c9f112f481b0d9d6a2fd2
parentaa54f9b070c8e0fe068fdba13b291f97abb8c0fb (diff)
downloadcombo-wip/37431-skeleton-do-not-consider-empty-url.zip
combo-wip/37431-skeleton-do-not-consider-empty-url.tar.gz
combo-wip/37431-skeleton-do-not-consider-empty-url.tar.bz2
skeleton: do not consider empty redirection URL (#37431)wip/37431-skeleton-do-not-consider-empty-url
-rw-r--r--combo/public/views.py2
-rw-r--r--tests/test_public.py9
2 files changed, 11 insertions, 0 deletions
diff --git a/combo/public/views.py b/combo/public/views.py
index bf35b5e..6ed152d 100644
--- a/combo/public/views.py
+++ b/combo/public/views.py
@@ -253,6 +253,8 @@ def skeleton(request):
redirect_url = utils.get_templated_url(page.redirect_url)
except utils.TemplateError:
continue
+ if not redirect_url:
+ continue
if source.startswith(redirect_url):
if selected_page is None or len(redirect_url) > len(selected_page.get_redirect_url()):
selected_page = page
diff --git a/tests/test_public.py b/tests/test_public.py
index fdd495c..de3f2b9 100644
--- a/tests/test_public.py
+++ b/tests/test_public.py
@@ -331,6 +331,15 @@ def test_page_skeleton(app):
assert "This page doesn't exist" in resp.text
assert resp.status_code == 200
+ # do not consider empty redirection
+ Page.objects.all().delete()
+ page = Page(title='EmptyRedirection', slug='emptyredir', template_name='standard',
+ redirect_url='{{ is_empty }}')
+ page.save()
+ resp = app.get('/__skeleton__/?source=%s' % quote('http://127.0.0.1:8999/'))
+ # resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net/bar/'))
+ assert resp.headers['x-combo-page-id'] == '__root'
+
def test_subpage_location(app):
Page.objects.all().delete()